You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code will not compile in Visual Studio 2015 (15.4.4) with the latest nlohmann::json code:
const nlohmann::json test;
const auto *s = test.get<const std::string*>();
The error message is:
1>F:\rolecraft2\prj\rolecraft\ui\ui_view_character.cpp(13): error C2668: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::get': ambiguous call to overloaded function
1>F:\rolecraft2\ext\nlohmann\json.hpp(9669): note: could be 'const PointerType nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::get<const std::string*,0>(void) noexcept const'
1> with
1> [
1> PointerType=const std::string *
1> ]
1>F:\rolecraft2\ext\nlohmann\json.hpp(9657): note: or 'PointerType nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::get<const std::string*,0>(void) noexcept'
1> with
1> [
1> PointerType=const std::string *
1> ]
1>F:\rolecraft2\ext\nlohmann\json.hpp(9567): note: or 'ValueType nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::get<const std::string*,const std::string*,0>(void) noexcept(<expr>) const'
1> with
1> [
1> ValueType=const std::string *
1> ]
Seems like Visual Studio's compiler can't decide whether to use ValueType version of get(), or PointerType one. The issue is easily worked around by using get_ptr() instead, but I still would like to report it, as it was working in older versions of the library (2.0.5, for example).
The issue can be fixed by adding
not std::is_pointer<ValueType>::value and
to enable_if template of ValueType get() const noexcept method.
The text was updated successfully, but these errors were encountered:
Yes, it worked before 2.10, until user defined conversions were added.
There has been some thoughts about whether or not we should allow user defined conversions for pointers.
Another option would be to delegate some calls to get_ptr (the same thing goes for reference arguments), which should work well unless we add support for pointer conversions. In that case there would be some tricky corner cases with basic types like basic_json::string_t.
This code will not compile in Visual Studio 2015 (15.4.4) with the latest nlohmann::json code:
The error message is:
Seems like Visual Studio's compiler can't decide whether to use ValueType version of get(), or PointerType one. The issue is easily worked around by using get_ptr() instead, but I still would like to report it, as it was working in older versions of the library (2.0.5, for example).
The issue can be fixed by adding
to enable_if template of ValueType get() const noexcept method.
The text was updated successfully, but these errors were encountered: