Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/nlohmann/detail/output/binary_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ class binary_writer
for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
{
oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
oa->write_character(j.m_data.m_value.binary->data()[i]);
oa->write_character(to_char_type(j.m_data.m_value.binary->data()[i]));
}
}

Expand Down Expand Up @@ -1634,7 +1634,9 @@ class binary_writer
};

string_t key = "_ArrayType_";
auto it = bjdtype.find(static_cast<string_t>(value.at(key)));
// use get<string_t>() instead of static_cast<string_t> to avoid an
// ambiguous conversion under explicit instantiation on C++17 (see #4825)
auto it = bjdtype.find(value.at(key).template get<string_t>());
if (it == bjdtype.end())
{
return true;
Expand Down
2 changes: 1 addition & 1 deletion include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4280,7 +4280,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
};

data m_data = {};
data m_data = {}; // NOLINT(readability-redundant-member-init)

#if JSON_DIAGNOSTICS
/// a pointer to a parent value (for debugging purposes)
Expand Down
8 changes: 5 additions & 3 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17076,7 +17076,7 @@ class binary_writer
for (size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
{
oa->write_character(to_char_type(bjdata_draft3 ? 'B' : 'U'));
oa->write_character(j.m_data.m_value.binary->data()[i]);
oa->write_character(to_char_type(j.m_data.m_value.binary->data()[i]));
}
}

Expand Down Expand Up @@ -17829,7 +17829,9 @@ class binary_writer
};

string_t key = "_ArrayType_";
auto it = bjdtype.find(static_cast<string_t>(value.at(key)));
// use get<string_t>() instead of static_cast<string_t> to avoid an
// ambiguous conversion under explicit instantiation on C++17 (see #4825)
auto it = bjdtype.find(value.at(key).template get<string_t>());
if (it == bjdtype.end())
{
return true;
Expand Down Expand Up @@ -24798,7 +24800,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
}
};

data m_data = {};
data m_data = {}; // NOLINT(readability-redundant-member-init)

#if JSON_DIAGNOSTICS
/// a pointer to a parent value (for debugging purposes)
Expand Down
10 changes: 10 additions & 0 deletions tests/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ using ordered_json = nlohmann::ordered_json;
#endif
#endif

/////////////////////////////////////////////////////////////////////
// for #4825 - explicitly instantiating basic_json must compile; this
// forces instantiation of binary_writer::write_bjdata_ndarray, whose
// static_cast<string_t> was ambiguous under explicit instantiation on
// C++17. Merely compiling this translation unit is the regression test.
/////////////////////////////////////////////////////////////////////
template class nlohmann::basic_json<>;

/////////////////////////////////////////////////////////////////////
// for #4440
/////////////////////////////////////////////////////////////////////
#if JSON_HAS_RANGES == 1
#include <ranges>
#endif
Expand Down
Loading