Fix CI failures on develop from the API performance stack

- Mark the parameters of the new out-of-line throw helpers in json.hpp as
  used, as JSON_THROW drops its argument with JSON_NOEXCEPTION (clang
  -Wunused-parameter).
- all_children_leaves() iterates with begin()/end() via std::all_of: a
  custom array_t such as the one in the custom_array_type example has no
  rbegin() (examples check, clang-tidy readability-use-anyofallof).
- The rvalue to_json overloads (#5837) copy the elements of containers
  with const elements such as std::set instead of moving them: GCC 4.9's
  std::move_iterator cannot bind them. Object types are ruled out before
  std::ranges::view is checked, which needs an incomplete ordered_json
  for its object_t (GCC 11, C++20, unit-regression3 #3312).
- NOLINT the rvalue to_json parameters that are deliberately not
  forwarded, and fix the other clang-tidy findings (modernize-use-auto in
  zmij.hpp, readability-math-missing-parentheses in json_pointer.hpp).
- cpplint: NOLINT(readability/braces) on the new scalar fast-path macro
  like on JSON_IMPLEMENT_OPERATOR, and include <map> in json.hpp.
- Tests: drop a useless cast (GCC -Wuseless-cast) and a signed/unsigned
  comparison (MSVC C4018), wrap a vector<json> comparison in parentheses
  so doctest does not try to print it (ambiguous operator<< on MSVC), and
  also strip JSON_DIAGNOSTIC_POSITIONS' "(bytes x-y) " from the patch
  messages in unit-throw_messages.
- Windows clang (MinGW): link with LLD. unit-msgpack.cpp (C++11) and
  unit-regression2.cpp (C++20) have more than 32767 sections again
  (33363 and 33197), which GNU ld cannot link; LLD links them.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-16 07:35:54 +02:00
1 parent 5683f5e024
commit 94d77f8d8d
10 files changed
+137 -67

No files matched your search

+1 -1
View File
@@ -300,7 +300,7 @@ TEST_CASE("copy constructor and destructor across value types")
REQUIRE(v.size() == 70);
std::vector<json> copy(v);
CHECK(copy == v);
CHECK((copy == v));
// mutating the copy leaves the original alone
copy[5] = "changed";
+1 -1
View File
@@ -1234,7 +1234,7 @@ TEST_CASE("JSON pointer array index tokens match strtoull semantics")
const std::string alphabet = "0123456789012345678901234567890123456789-+ ex";
for (int i = 0; i < 5000; ++i)
{
std::string token(static_cast<std::size_t>(gen() % 23), '0');
std::string token(gen() % 23, '0');
for (auto& c : token)
{
c = alphabet[gen() % alphabet.size()];
+1 -1
View File
@@ -1489,7 +1489,7 @@ TEST_CASE("invalid UTF-8 at every position is handled like the reference")
{
for (const auto& pattern : patterns)
{
check_dump_against_reference(make_string(filler, pos, pattern, length - pos), bytes <= (filler.size() == 1 ? 17 : 8));
check_dump_against_reference(make_string(filler, pos, pattern, length - pos), bytes <= (filler.size() == 1 ? 17u : 8u));
}
}
}
+10 -4
View File
@@ -105,12 +105,18 @@ TEST_CASE("exception messages of out-of-line throw sites")
}
catch (const json::exception& e)
{
// with JSON_DIAGNOSTICS, what() names the offending value like "(/0) "; drop it
// with JSON_DIAGNOSTICS, what() names the offending value like "(/0) ",
// and with JSON_DIAGNOSTIC_POSITIONS its position like "(bytes 0-2) "; drop both
std::string msg = e.what();
const auto pos = msg.find(" (/");
if (pos != std::string::npos)
for (const char* marker :
{" (/", " (bytes "
})
{
msg.erase(pos + 1, msg.find(") ", pos) - pos + 1);
const auto pos = msg.find(marker);
if (pos != std::string::npos)
{
msg.erase(pos + 1, msg.find(") ", pos) - pos + 1);
}
}
return msg;
}