Skip to content
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

Move UDLs out of the global namespace #3605

Merged
merged 11 commits into from
Jul 31, 2022

Conversation

falbrechtskirchinger
Copy link
Contributor

@falbrechtskirchinger falbrechtskirchinger commented Jul 24, 2022

Moves the UDLs into nlohmann::literals::json_literals. See https://en.cppreference.com/w/cpp/chrono/operator%22%22h#Notes.

The UDLs can be brought into scope using any of the following lines:

using namespace nlohmann;
using namespace nlohmann::literals;
using namespace nlohmann::json_literals;
using namespace nlohmann::literals::json_literals;

Alternatively, the old behavior can be restored by defining the macro JSON_USE_GLOBAL_UDLS to 1, which puts the UDLs back into the global namespace.

Depends on #3590.
Fixes #1682.

To Do:

  • Update documentation.
  • Update uses of UDLs (examples, ...).
  • Add unit tests for all using namespace lines.

@coveralls
Copy link

coveralls commented Jul 24, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling c94ed06 on falbrechtskirchinger:inline-ns-udls into d3e347b on nlohmann:develop.

README.md Show resolved Hide resolved
Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nlohmann nlohmann self-assigned this Jul 31, 2022
@nlohmann nlohmann added this to the Release 3.11.0 milestone Jul 31, 2022
@nlohmann nlohmann mentioned this pull request Jul 31, 2022
@nlohmann nlohmann merged commit 9aafcbe into nlohmann:develop Jul 31, 2022
@falbrechtskirchinger falbrechtskirchinger deleted the inline-ns-udls branch July 31, 2022 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider putting the user-defined literals in a namespace
3 participants