Skip to content

Compilation error getting a std::pair<> on latest VS 2017 compiler #1506

@pmhpereira

Description

@pmhpereira
  • What is the issue you have?
    Compilation error on latest Visual Studio 2017 compiler.
    Works with Visual Studio 2015 compiler.
error C2679: binary '=': no operator found which takes a right-hand operand of type 
'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>' 
(or there is no acceptable conversion)
  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
int main()
{
    nlohmann::json jsonTest;

    std::pair<int, int> intPair(10, 20);

    jsonTest["intPair"] = intPair;
    intPair = jsonTest["intPair"]; // compilation error on this line
}
  • What is the expected behavior?
    Same as intPair = jsonTest["intPair"].get<std::pair<int,int>>();

  • Which compiler and operating system are you using? Is it a supported compiler?
    -- Building for: Visual Studio 15 2017
    -- The CXX compiler identification is MSVC 19.16.27027.1
    -- Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
    -- Windows 10

  • Did you use a released version of the library or the version from the develop branch?
    Release v3.5.0

  • If you experience a compilation error: can you compile and run the unit tests?
    Can compile. No errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions