json icon indicating copy to clipboard operation
json copied to clipboard

Split inline namespace and allow version namespace to be disabled

Open falbrechtskirchinger opened this issue 2 years ago • 7 comments

Split the versioned, ABI-tagged inline namespace into separate tag and version namespaces.

Example: nlohmann::nlohmann_json_diag::v3_11_1

The prefix of the tag namespace cannot be json as that would conflict with the type alias nlohmann::json.

~~The version namespace can be disabled by defining NLOHMANN_JSON_NAMESPACE_VERSION_NAMESPACE without a value. The long macro name is unfortunate, but NLOHMANN_JSON_VERSION_NAMESPACE doesn't sort well and NLOHMANN_JSON_NAMESPACE_VERSION sounds confusing.~~

falbrechtskirchinger avatar Aug 06 '22 15:08 falbrechtskirchinger

Coverage Status

Coverage remained the same at 100.0% when pulling 5385b0562b15c2fce127e07f3aee83e9f1bff189 on falbrechtskirchinger:inline-ns-update into a92ccafd2c7709243451e947a21ad08203273483 on nlohmann:develop.

coveralls avatar Aug 06 '22 15:08 coveralls

What is the benefit of having the version part a separate namespace that may or may not be used instead of just a part of the name that may or may not be there?

gregmarr avatar Aug 06 '22 17:08 gregmarr

It just expresses the hierarchy between the truly (and always) ABI-breaking settings and library versions. I don't really know yet if that's useful, but I don't think it hurts either.

falbrechtskirchinger avatar Aug 06 '22 17:08 falbrechtskirchinger

ci_test_single_header failing is expected until #3679 is merged.

falbrechtskirchinger avatar Aug 07 '22 07:08 falbrechtskirchinger

Is there a way to get back to the original behavior and just have a nlohmann namespace with basic_json right in it without inline namespaces?

nlohmann avatar Aug 07 '22 12:08 nlohmann

Yes. Since 3.11.0. https://github.com/nlohmann/json/issues/3657#issuecomment-1207175931 (And the test has been added to this PR.)

falbrechtskirchinger avatar Aug 07 '22 12:08 falbrechtskirchinger

I've added a first, rough version of features/namespace.md. Clearly needs more polish in the future. Looking forward to incorporating any suggestions you may have.

falbrechtskirchinger avatar Aug 07 '22 14:08 falbrechtskirchinger

Here's how the plantuml diagram in features/namespace.md renders:

namespace md_uml

falbrechtskirchinger avatar Aug 09 '22 14:08 falbrechtskirchinger