Skip to content

Use the with_*_t aliases in tests, examples, and docs - #5787

Merged
nlohmann merged 4 commits into
developfrom
refactor/use-with-aliases
Oct 8, 2026
Merged

nlohmann merged 4 commits into
developfrom
refactor/use-with-aliases

Conversation

@nlohmann

@nlohmann nlohmann commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #5758, as suggested in #5758 (comment). Replaces spelled-out basic_json<...> instantiations in tests, examples, and docs with nlohmann::json::with_*_t (ordered_json::with_*_t where the object type is ordered_map). Types that change all three number types chain with_integers_t<…>::with_float_t<…>. The raw spelling stays where the template parameter list itself is the subject (alias tests in unit-udt.cpp, explicit instantiations, ordered_json/compile-time docs).

Also fixes CI on develop (7ffa409, cc02d10, 9be1ddb): #5781 was merged while its CI was cancelled and left two problems in tests/src/unit-large_json.cpp. CAPTURE(depth); trips clang's -Wextra-semi-stmt (ci_test_clang, ci_test_standards_clang), and the type_error.321 checks did not expect the (/0/…) path prefix that JSON_DIAGNOSTICS adds (ci_test_diagnostics). In addition, #5772 left functional casts in tests/src/unit-hash.cpp that clang-tidy reports as C-style casts (ci_clang_tidy).

Public API: no breaking changes. Only tests, examples, and documentation are touched.

🤖 Generated with Claude Code

Replace spelled-out basic_json<...> instantiations that only change one
or two template parameters with nlohmann::json::with_*_t (or
ordered_json::with_*_t when the object type is ordered_map). Types that
change all three number types chain with_integers_t and with_float_t.

The raw basic_json<...> spelling stays where the template parameter
list itself is the subject: the alias tests in unit-udt.cpp, explicit
instantiations, and the ordered_json/compile-time docs.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Two test problems from #5781 broke CI on develop: CAPTURE(depth); trips
clang's -Wextra-semi-stmt, and the type_error.321 messages did not
account for the diagnostics path prefix.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
#5772 added functional casts that clang-tidy reports as C-style casts
(google-readability-casting). Also append a char instead of a
one-character string in unit-large_json.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Without JSON_DIAGNOSTICS the prefix was never modified, which
clang-tidy reports (misc-const-correctness).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann
nlohmann merged commit 3d7f554 into develop Oct 8, 2026
272 of 275 checks passed
@nlohmann nlohmann added this to the Release 3.13.0 milestone Oct 8, 2026
@nlohmann
nlohmann deleted the refactor/use-with-aliases branch October 8, 2026 14:11
@gregmarr

gregmarr commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

nlohmann added a commit that referenced this pull request Oct 9, 2026
#5787 missed the instantiations spelled as `basic_json <` (astyle's
formatting) or ending in the CustomBaseClass argument. Convert them,
including the binary_t.md example pointed out in review.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants