Skip to content

Library provides template arg for string_type but assumes std::string in some places #2059

@ghost

Description

I'm using json object with Electronic Arts' EASTL library, which provides high performance implementations of std containers. I use the following typedef:

    using stdjson = nlohmann::basic_json<std::map,
                                         std::vector,
                                         stdstring,
                                         bool,
                                         int64_t,
                                         uint64_t,
                                         double,
                                         jsonallocator,
                                         nlohmann::adl_serializer>;

where stdstring is eastl::string, which is their version of std::string. Then throughout my code, I just always use stdjson type. This works great, except for when json code assumes std::string. For example, this code:

   for (auto& cam : sjson["cameras"].items()) {
        stdstring cameraname(cam.key());
    }

fails to compile because of this code in iteration_proxy.hpp:

template<typename string_type>
void int_to_string( string_type& target, std::size_t value )
{
    target = std::to_string(value);
}

which assumes std::string is the string_type. I'm using Visual Studio 2019 on Windows 10 using the latest release of json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions