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

std::begin and std::end usage without specifying std namespace #2359

Closed
themarpe opened this issue Aug 18, 2020 · 2 comments
Closed

std::begin and std::end usage without specifying std namespace #2359

themarpe opened this issue Aug 18, 2020 · 2 comments
Labels
kind: bug state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@themarpe
Copy link

What is the issue you have?

Name clash with "end" symbol

Working with an existing code base, where an extern int end; is declared in one of header files causes ambiguity.

Please describe the steps to reproduce the issue.

int end;
#include <nlohmann/json.hpp>
int main() { return 0; }

What is the expected behavior?

That library uses std::begin/std::end and avoids the ambiguity with other symbols from global namespace.

The issue seem to only appear in line 5094 (json.hpp, single header):

auto input_adapter(const ContainerType& container) -> decltype(input_adapter(begin(container), end(container)))

Following change seems to fix the issue:

auto input_adapter(const ContainerType& container) -> decltype(input_adapter(std::begin(container), std::end(container)))

Which compiler and operating system are you using?

  • Compiler: g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
  • Operating system: Ubuntu 18.04

Which version of the library did you use?

  • latest release version 3.9.1
@gregmarr
Copy link
Contributor

Also #2248

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Sep 20, 2020
@stale stale bot closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

2 participants