mirror of
https://github.com/nlohmann/json.git
synced 2026-05-15 02:35:24 +00:00
Fix incomplete-type error in set_parents with ordered_json (#5167)
When iteration_proxy_value<iter_impl<ordered_json>> appears in a context
that requires it to be complete (function or lambda parameter), the
compiler instantiates basic_json<ordered_map> and walks into
set_parents(iterator, typename iterator::difference_type)
while iterator is still incomplete, failing with "invalid use of
incomplete type".
basic_json::difference_type is already std::ptrdiff_t, so just naming
the underlying type directly avoids the dependent lookup. Behavior and
ABI are unchanged. This was the approach suggested in the issue thread.
Added a regression case in unit-ordered_json.cpp using the same trigger
pattern (lambda parameter naming the proxy type).
Fixes #3732
Signed-off-by: Akhilesh Arora <akhildawra@gmail.com>
This commit is contained in:
@@ -21020,10 +21020,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
#endif
|
||||
}
|
||||
|
||||
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
|
||||
iterator set_parents(iterator it, std::ptrdiff_t count_set_parents)
|
||||
{
|
||||
#if JSON_DIAGNOSTICS
|
||||
for (typename iterator::difference_type i = 0; i < count_set_parents; ++i)
|
||||
for (std::ptrdiff_t i = 0; i < count_set_parents; ++i)
|
||||
{
|
||||
(it + i)->m_parent = this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user