The JSON pointer example produces compiler warning.
I want to access the json node with json_pointer without compiler warning. If I follow the warning by using to_string method, the meaning is totally different and causes runtime exception.
reference at(const json_pointer& ptr)
template<class KeyType, detail::enable_if_t<
detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
reference at(KeyType && key)
given by g++-11 (similar is from g++-13):
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp: In instantiation of ‘struct nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char>, nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&, void>’:
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_12_0::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_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::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_12_0::detail::is_json_iterator_of<nlohmann::json_abi_v3_12_0::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_12_0::basic_json<>::at<KeyType, <anonymous> >(KeyType&&) const [with KeyType = nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&; typename std::enable_if<typename std::conditional<(typename std::conditional<(((nlohmann::json_abi_v3_12_0::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_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::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_12_0::detail::is_json_iterator_of<nlohmann::json_abi_v3_12_0::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>]’
main.cpp:20:21: required from here
include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp: In instantiation of ‘struct nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&, void>’:
include/nlohmann/json.hpp:2328:20: required by substitution of ‘template<class ValueType, class KeyType, class ReturnType, typename std::enable_if<((((nlohmann::json_abi_v3_12_0::detail::is_transparent<std::less<std::__cxx11::basic_string<char> > >::value && (! nlohmann::json_abi_v3_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::json_pointer, typename std::remove_cv<typename std::remove_reference<_Arg>::type>::type>::value)) && nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, KeyType, void>::value) && nlohmann::json_abi_v3_12_0::detail::is_getable<nlohmann::json_abi_v3_12_0::basic_json<>, ReturnType>::value) && (! std::is_same<nlohmann::json_abi_v3_12_0::detail::value_t, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), int>::type <anonymous> > ReturnType nlohmann::json_abi_v3_12_0::basic_json<>::value<ValueType, KeyType, ReturnType, <anonymous> >(KeyType&&, ValueType&&) const [with ValueType = int; KeyType = nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&; ReturnType = int; typename std::enable_if<((((nlohmann::json_abi_v3_12_0::detail::is_transparent<std::less<std::__cxx11::basic_string<char> > >::value && (! nlohmann::json_abi_v3_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::json_pointer, typename std::remove_cv<typename std::remove_reference<_Arg>::type>::type>::value)) && nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, KeyType, void>::value) && nlohmann::json_abi_v3_12_0::detail::is_getable<nlohmann::json_abi_v3_12_0::basic_json<>, ReturnType>::value) && (! std::is_same<nlohmann::json_abi_v3_12_0::detail::value_t, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), int>::type <anonymous> = <missing>]’
main.cpp:21:24: required from here
include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
In file included from include/nlohmann/detail/exceptions.hpp:25,
from include/nlohmann/detail/conversions/from_json.hpp:26,
from include/nlohmann/adl_serializer.hpp:14,
from include/nlohmann/json.hpp:34,
from main.cpp:1:
include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50,
from main.cpp:1:
include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here
81 | operator string_t() const
| ^~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:21:10: warning: unused variable ‘val3’ [-Wunused-variable]
21 | auto val3 = j.value(p2, 0); // 0
| ^~~~
Description
The JSON pointer example produces compiler warning.
Reproduction steps
Note:
clang++-14 and clang++-18 compiles the same code without the deprecated-declarations warning.
Expected vs. actual results
I want to access the json node with json_pointer without compiler warning. If I follow the warning by using to_string method, the meaning is totally different and causes runtime exception.
To be specific, the parameter p1 should be binded to
but its binded to
Minimal code example
Error messages
given by g++-11 (similar is from g++-13): In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp: In instantiation of ‘struct nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char>, nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&, void>’: 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_12_0::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_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::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_12_0::detail::is_json_iterator_of<nlohmann::json_abi_v3_12_0::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_12_0::basic_json<>::at<KeyType, <anonymous> >(KeyType&&) const [with KeyType = nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&; typename std::enable_if<typename std::conditional<(typename std::conditional<(((nlohmann::json_abi_v3_12_0::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_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::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_12_0::detail::is_json_iterator_of<nlohmann::json_abi_v3_12_0::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>]’ main.cpp:20:21: required from here include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp: In instantiation of ‘struct nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&, void>’: include/nlohmann/json.hpp:2328:20: required by substitution of ‘template<class ValueType, class KeyType, class ReturnType, typename std::enable_if<((((nlohmann::json_abi_v3_12_0::detail::is_transparent<std::less<std::__cxx11::basic_string<char> > >::value && (! nlohmann::json_abi_v3_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::json_pointer, typename std::remove_cv<typename std::remove_reference<_Arg>::type>::type>::value)) && nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, KeyType, void>::value) && nlohmann::json_abi_v3_12_0::detail::is_getable<nlohmann::json_abi_v3_12_0::basic_json<>, ReturnType>::value) && (! std::is_same<nlohmann::json_abi_v3_12_0::detail::value_t, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), int>::type <anonymous> > ReturnType nlohmann::json_abi_v3_12_0::basic_json<>::value<ValueType, KeyType, ReturnType, <anonymous> >(KeyType&&, ValueType&&) const [with ValueType = int; KeyType = nlohmann::json_abi_v3_12_0::json_pointer<std::__cxx11::basic_string<char> >&; ReturnType = int; typename std::enable_if<((((nlohmann::json_abi_v3_12_0::detail::is_transparent<std::less<std::__cxx11::basic_string<char> > >::value && (! nlohmann::json_abi_v3_12_0::detail::is_specialization_of<nlohmann::json_abi_v3_12_0::json_pointer, typename std::remove_cv<typename std::remove_reference<_Arg>::type>::type>::value)) && nlohmann::json_abi_v3_12_0::detail::is_comparable<std::less<std::__cxx11::basic_string<char> >, const std::__cxx11::basic_string<char>&, KeyType, void>::value) && nlohmann::json_abi_v3_12_0::detail::is_getable<nlohmann::json_abi_v3_12_0::basic_json<>, ReturnType>::value) && (! std::is_same<nlohmann::json_abi_v3_12_0::detail::value_t, typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value)), int>::type <anonymous> = <missing>]’ main.cpp:21:24: required from here include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:568:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ In file included from include/nlohmann/detail/exceptions.hpp:25, from include/nlohmann/detail/conversions/from_json.hpp:26, from include/nlohmann/adl_serializer.hpp:14, from include/nlohmann/json.hpp:34, from main.cpp:1: include/nlohmann/detail/meta/type_traits.hpp:569:33: warning: ‘nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::operator nlohmann::json_abi_v3_12_0::json_pointer<RefStringType>::string_t() const [with RefStringType = std::__cxx11::basic_string<char>; nlohmann::json_abi_v3_12_0::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 include/nlohmann/json.hpp:50, from main.cpp:1: include/nlohmann/detail/json_pointer.hpp:81:5: note: declared here 81 | operator string_t() const | ^~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:21:10: warning: unused variable ‘val3’ [-Wunused-variable] 21 | auto val3 = j.value(p2, 0); // 0 | ^~~~Compiler and operating system
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1
22.04.2) / gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu122.04)Library version
nlohmann json 3.12.0
Validation
developbranch is used.