Skip to content

C++17's ambiguous conversion #586

Description

@Krysme

In c++ 17, std::string_view can be converted to std::string implicitly which leads to a problem that in c++17 mode , a json object cannot be assigned to a string due to ambiguous assigning conversion path ( json --> string and json --> string_view --> string).

In gcc 7.1 such code produces a compilation error width -std=c++1z.

code:

#include "json.hpp"
#include <string>


int main()
{

    nlohmann::json j;
    j = "12345";
    std::string s;
    s = j;

    return 0;
}

So, is it possible to remove the conversion to string specifically in c++17 mode to let the compiler select the json--> string_view --> string path ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions