Repository navigation
Document options to reduce compile times - #5611
Merged
Merged
Conversation
nlohmann
added this pull request to stack #5612
September 28, 2026 20:02
nlohmann
force-pushed
the
claude/compile-time-docs
branch
from
September 29, 2026 14:41
5ab47ef to
d324da8
Compare
Add an integration page that collects the ways to reduce compile times with measurements: json_fwd.hpp in headers, JSON_NO_AUTOMATIC_UDLS, explicit instantiation with extern template, modules, and precompiled headers, and notes that JSON_NO_IO and JSON_USE_GLOBAL_UDLS have no measurable effect. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
force-pushed
the
claude/compile-time-docs
branch
from
September 30, 2026 18:08
d324da8 to
023ab67
Compare
gregmarr
reviewed
Oct 4, 2026
|
|
||
| ```cpp | ||
| #include <nlohmann/json.hpp> | ||
| #include <nlohmann/json_literals.hpp> // only where "..."_json is used |
Contributor
There was a problem hiding this comment.
json_literals.hpp includes json.hpp so this is promoting extra cost. Either json_literals.hpp doesn't include json.hpp or this recommends just including json_literals.hpp. I would be fine with either version.
Owner
Author
There was a problem hiding this comment.
Thanks, done in 2ce78e1: the example (here and in the JSON_NO_AUTOMATIC_UDLS page) now includes only <nlohmann/json_literals.hpp> and mentions that it brings in <nlohmann/json.hpp>.
(Written by Claude Code.)
json_literals.hpp includes json.hpp itself, so including both is redundant. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5610. Adds the documentation page Integration › Compile times, which collects the options discussed in #5294 to reduce compile times, each with measurements (C++17, Apple clang and GCC 16,
-O0/-O2, median of 9 runs):json_fwd.hppin headersjsonJSON_NO_AUTOMATIC_UDLS(#5610) +json_literals.hppwhere neededextern template class nlohmann::basic_json<>;+ one explicit instantiation TUjsonJSON_NO_IO,JSON_USE_GLOBAL_UDLS=0I compiled and linked the
extern templateexample with clang (C++11/17) and GCC 16 (C++17). The page also notes that member templates (get<T>(),parse(...)) are not covered by the explicit instantiation, and thatordered_jsonneeds its own lines.Also links the page from the integration index and the
JSON_NO_AUTOMATIC_UDLSpage, and adds it to the navigation.Public API
No changes. This is documentation only.
This PR description was written by Claude Code.
🤖 Generated with Claude Code