-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate template functions with NLOHMANN_DEFINE_TYPE macros #4597
base: develop
Are you sure you want to change the base?
Generate template functions with NLOHMANN_DEFINE_TYPE macros #4597
Conversation
9f84443
to
b22b43a
Compare
On second thought, I can use |
(I'm only commenting on the CI issues right now: Clang-Tidy should be fixable by just adding some |
The coverage job is now fixed in the |
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
Signed-off-by: kimci86 <kimci86@hotmail.fr>
749b983
to
43c41f0
Compare
Changes:
NLOHMANN_DEFINE_TYPE_*
generate template functions. This allows to use any specialization ofnlohmann::basic_json
such asnlohmann::ordered_json
, instead ofnlohmann::json
only.Existing issues:
Related PRs:
Reviews on related PRs have raised the following concerns:
to_json
/from_json
becoming a template change overload resolution is some twisted cases.BasicJsonType
is not restricted tobasic_json
instances.To be noted:
NLOHMANN_JSON_SERIALIZE_ENUM
already uses that same design of unrestrictedBasicJsonType
template parameter.If we want to restrict it, I see two options:
is_basic_json
.Currently
include/nlohmann/detail/meta/type_traits.hpp
includesinclude/nlohmann/detail/macro_scope.hpp
so we cannot useis_basic_json
in macros.#undef
NLOHMANN_BASIC_JSON_TPL_DECLARATION
andNLOHMANN_BASIC_JSON_TPL
inmacro_unscope.hpp
so that we can use them in macros to effectively write the fullbasic_json
template type.What do you think?
Thank you for this awesome library!
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filessingle_include/nlohmann/json.hpp
andsingle_include/nlohmann/json_fwd.hpp
. The whole process is described here.