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
{{ message }}
Repository navigation
Using iteration_proxy_value with ordered_json fails to compile due to incomplete type #3732
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());
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>'
Do you know why this only happens with ordered_json and not the regular json? Is it possible for a user to hit this without using types from the detail namespace?
I'm not entirely certain in what way the order of template instantiation changes with ordered_json. I suspect it's related to object_t::key_type and how that is derived in various places. When I deduced the type instead of spelling it out, the error went away. I don't know if it's possible to trigger this error without directly using types from detail, but I think it warrants further investigation.
I think template class iter_impl and ordered_json depend on each other when we use nlohmann::detail::iter_impl<nlohmann::ordered_json>. So nlohmann::ordered_json should be explicit instantiate beforehand.
Activity
gregmarr commentedon Sep 8, 2022
Do you know why this only happens with
ordered_jsonand not the regularjson? Is it possible for a user to hit this without using types from thedetailnamespace?falbrechtskirchinger commentedon Sep 8, 2022
I'm not entirely certain in what way the order of template instantiation changes with
ordered_json. I suspect it's related toobject_t::key_typeand how that is derived in various places. When I deduced the type instead of spelling it out, the error went away. I don't know if it's possible to trigger this error without directly using types fromdetail, but I think it warrants further investigation.luistung commentedon Sep 15, 2022
I think template class
iter_implandordered_jsondepend on each other when we usenlohmann::detail::iter_impl<nlohmann::ordered_json>. Sonlohmann::ordered_jsonshould be explicit instantiate beforehand.nlohmann commentedon Nov 29, 2024
Alternatively, I can change the
count_set_parentsparameter ofset_parentstointorstd::ptrdiff_t- then your example compiles.Fix incomplete-type error in set_parents with ordered_json (#5167)
Fix incomplete-type error in set_parents with ordered_json (nlohmann#…
Fix incomplete-type error in set_parents with ordered_json (nlohmann#…