Open garethsb opened 1 year ago
I have the same problem. I am compiling with gcc 7.5.0 and c++11. When I disable deprecated warnings with -Wno-deprecated-declarations then the code compiles without issues. But it seems that this was a desired change to deprecate using a json_pointer with the at() and operator[] functions?
I am also having this problem.
My problem was that I was using nlohmann::json_pointer<nlohmann::json> {"path/here"}
instead of nlohmann::json::json_pointer("path/here")
.
Changing all the uses from one version to the other solved the problem.
Is there any workaround for this problem? I hate adding -Wno-deprecated-declarations
I have same issue. I am using v3.11.3. this is the message:
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/exceptions.hpp:25,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/conversions/from_json.hpp:23,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/adl_serializer.hpp:14,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:34,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp: In instantiation of 'struct nlohmann::json_abi_v3_11_3::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char>, nlohmann::json_abi_v3_11_3::json_pointer<std::__cxx11::basic_string<char> >&, void>':
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp:581:31: required by substitution of 'template<class KeyType, typename std::enable_if<typename std::conditional<(typename std::conditional<(((nlohmann::json_abi_v3_11_3::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char>, KeyType, void>::value && (!(true && std::is_same<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::__cxx11::basic_string<char> >::value))) && ((! true) || std::integral_constant<bool, false>::value)) && (! nlohmann::json_abi_v3_11_3::detail::is_specialization_of<nlohmann::json_abi_v3_11_3::json_pointer, typename std::remove_cv<typename std::remove_reference<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::type>::type>::value)), std::integral_constant<bool, true>, std::integral_constant<bool, false> >::type::value && (! nlohmann::json_abi_v3_11_3::detail::is_json_iterator_of<nlohmann::json_abi_v3_11_3::basic_json<>, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), std::integral_constant<bool, true>, std::integral_constant<bool, false> >::type::value, int>::type <anonymous> > const value_type& nlohmann::json_abi_v3_11_3::basic_json<>::at<KeyType, <anonymous> >(KeyType&&) const [with KeyType = nlohmann::json_abi_v3_11_3::json_pointer<std::__cxx11::basic_string<char> >&; typename std::enable_if<typename std::conditional<(typename std::conditional<(((nlohmann::json_abi_v3_11_3::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char>, KeyType, void>::value && (!(true && std::is_same<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::__cxx11::basic_string<char> >::value))) && ((! true) || std::integral_constant<bool, false>::value)) && (! nlohmann::json_abi_v3_11_3::detail::is_specialization_of<nlohmann::json_abi_v3_11_3::json_pointer, typename std::remove_cv<typename std::remove_reference<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::type>::type>::value)), std::integral_constant<bool, true>, std::integral_constant<bool, false> >::type::value && (! nlohmann::json_abi_v3_11_3::detail::is_json_iterator_of<nlohmann::json_abi_v3_11_3::basic_json<>, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), std::integral_constant<bool, true>, std::integral_constant<bool, false> >::type::value, int>::type <anonymous> = <missing>]'
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:4756:43: required from 'void nlohmann::json_abi_v3_11_3::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>::patch_inplace(const nlohmann::json_abi_v3_11_3::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_abi_v3_11_3::adl_serializer; BinaryType = std::vector<unsigned char>; CustomBaseClass = void]'
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:4973:16: required from 'nlohmann::json_abi_v3_11_3::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass> nlohmann::json_abi_v3_11_3::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>::patch(const nlohmann::json_abi_v3_11_3::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>&) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_abi_v3_11_3::adl_serializer; BinaryType = std::vector<unsigned char>; CustomBaseClass = void]'
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:61:32: required from here
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: 'nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t = std::__cxx11::basic_string<char>]' is deprecated: Since 3.11.0; use to_string() [-Wdeprecated-declarations]
568 | decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:50,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/exceptions.hpp:25,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/conversions/from_json.hpp:23,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/adl_serializer.hpp:14,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:34,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: 'nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t = std::__cxx11::basic_string<char>]' is deprecated: Since 3.11.0; use to_string() [-Wdeprecated-declarations]
569 | decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:50,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/exceptions.hpp:25,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/conversions/from_json.hpp:23,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/adl_serializer.hpp:14,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:34,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: 'nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t = std::__cxx11::basic_string<char>]' is deprecated: Since 3.11.0; use to_string() [-Wdeprecated-declarations]
568 | decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:50,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/exceptions.hpp:25,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/conversions/from_json.hpp:23,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/adl_serializer.hpp:14,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:34,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: 'nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_11_3::json_pointer<RefStringType>::string_t = std::__cxx11::basic_string<char>]' is deprecated: Since 3.11.0; use to_string() [-Wdeprecated-declarations]
569 | decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/json.hpp:50,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/json-schema-validator/src/nlohmann/json-schema.hpp:24,
from /mnt/c/Users/yukunlin/Documents/indoorjson-cpp/src/main.cpp:16:
/mnt/c/Users/yukunlin/Documents/indoorjson-cpp/dependencies/nlohmann_json/include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
FWIW with g++ 11.4 the warnings are present with -std=c++11
but not -std=c++14
.
Doesn't help me as my code base is currently stuck on c++11 but noting in case it is of use to anyone else.
Description
Deprecation of mixed type comparison operators of
json_pointer
seems to have resulted in unexpected deprecation warning when usingjson::at
withjson_pointer
, I think becauseis_comparable
is evaluated while calculating the overload candidates...Reproduction steps
Compile example with GCC against 3.11.2. Works OK with 3.11.1.
Expected vs. actual results
Expected:
No warnings.
Actual:
Several long-winded warnings.
Minimal code example
Error messages
Compiler and operating system
GCC (tried 12.2 back to 4.8)
Library version
3.11.2
Validation
develop
branch is used.