-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Description
Description
Using iteration_proxy_value with ordered_json as shown below fails to compile due to an incomplete type error in iterator set_parents(iterator it, typename iterator::difference_type count_set_parents).
The error can be avoided by altering the order of template instantiation by either forcing instantiation (undesirable; increases compile time for everyone) or rewriting set_parents() without iterator::difference_type.
Users facing this issue may force instantiation in the correct order using
using ItemType = decltype(*std::declval<nlohmann::ordered_json>().items().begin());before code triggering the compilation failure.
(Found via #3731.)
Reproduction steps
See code example.
Expected vs. actual results
Code should compile.
Minimal code example
void test(nlohmann::detail::iteration_proxy_value<
nlohmann::detail::iter_impl<nlohmann::ordered_json>> const& val) {
static_cast<void>(val.value());
}Error messages
GCC:
error: invalid use of incomplete type 'using nlohmann::json_abi_v3_11_2::basic_json<nlohmann::json_abi_v3_11_2::ordered_map>::iterator = nlohmann::json_abi_v3_11_2::basic_json<nlohmann::json_abi_v3_11_2::ordered_map>::iter_impl<nlohmann::json_abi_v3_11_2::basic_json<nlohmann::json_abi_v3_11_2::ordered_map> >' {aka 'class nlohmann::json_abi_v3_11_2::detail::iter_impl<nlohmann::json_abi_v3_11_2::basic_json<nlohmann::json_abi_v3_11_2::ordered_map> >'}
Clang:
error: no type named 'difference_type' in 'nlohmann::detail::iter_impl<nlohmann::basic_json<nlohmann::ordered_map>>'
MSVC:
error C2039: 'difference_type': is not a member of 'nlohmann::json_abi_v3_11_2::detail::iter_impl<nlohmann::json_abi_v3_11_2::ordered_json>'
Compiler and operating system
Compiler Explorer: GCC (trunk) / Clang (trunk) / MSVC latest
Library version
3.11.2/develop
Validation
- The bug also occurs if the latest version from the
developbranch is used. - I can successfully compile and run the unit tests.