mirror of
https://github.com/nlohmann/json.git
synced 2026-07-10 04:25:11 +00:00
8917c42bbc
The diagnostic matrix in this PR confirmed the affected range exactly: nvcc 12.0.1 and 12.1.1 both fail with "expected initializer before '<' token" on iteration_proxy.hpp's enable_borrowed_range variable template specialization at -std=c++20; 12.2.2 and newer already build cleanly. Guard JSON_HAS_RANGES off for that narrow nvcc version range, matching the existing GCC-11/libstdc++ carve-outs in the same ifdef chain, and regenerate single_include accordingly. Broaden the CUDA smoke test to also exercise comparisons (operator==/operator<=>, gated independently by JSON_HAS_THREE_WAY_COMPARISON) and range-based iteration, not just dump()/erase(), so the fix's actual scope is evidenced by CI rather than assumed from the single reported symptom. Have tests/cuda_example/CMakeLists.txt pick the newest C++ standard the detected nvcc version actually supports (20/17/11) instead of hard-requiring C++20, so older toolkits build at a lower standard instead of failing CMake configure outright. This is test-project-local only; the JSON_HAS_RANGES guard is what protects real client code, since a header can't control what -std= flag it's compiled with. Right-size the CI matrix from the 8-version diagnostic sweep down to 11.8.0 (C++17 fallback path) / 12.1.1 (permanent #3907 regression guard) / 12.6.3 (recent coverage), and update the compiler-version table in the quality assurance docs to match. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
// __ _____ _____ _____
|
|
// __| | __| | | | JSON for Modern C++ (supporting code)
|
|
// | | |__ | | | | | | version 3.12.0
|
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
|
//
|
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
int main()
|
|
{
|
|
nlohmann::ordered_json json = {"Test"};
|
|
json.dump();
|
|
|
|
// regression for #3013 (ordered_json::reset() compile error with nvcc)
|
|
nlohmann::ordered_json metadata;
|
|
metadata.erase("key");
|
|
|
|
// exercise comparisons (operator==/operator<=>, gated by
|
|
// JSON_HAS_THREE_WAY_COMPARISON, independent of JSON_HAS_RANGES) and
|
|
// range-based iteration (exercises iteration_proxy/ranges machinery
|
|
// beyond just the enable_borrowed_range specialization) — see #3907
|
|
nlohmann::json a = {1, 2, 3};
|
|
nlohmann::json b = {1, 2, 3};
|
|
static_cast<void>(a == b);
|
|
static_cast<void>(a <=> b); // *NOPAD*
|
|
static_cast<void>(a <=> 1); // *NOPAD*
|
|
for (const auto& element : a)
|
|
{
|
|
static_cast<void>(element);
|
|
}
|
|
}
|