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

Using back_inserter without the std:: prefix #4113

Closed
thraneh opened this issue Aug 8, 2024 · 3 comments
Closed

Using back_inserter without the std:: prefix #4113

thraneh opened this issue Aug 8, 2024 · 3 comments

Comments

@thraneh
Copy link

thraneh commented Aug 8, 2024

I have a custom container with appropriate iterators, push_back method, etc. This used to work up until fmt 10.0.2

I haven't yet been able to set up a minimal example to reproduce this.

However, the issue arise from this line where back_inserter is used without the std:: prefix (maybe you wanted to use your own invoke_back_inserter?)

The issue was seen when compiling C++23

GCC 14.1.0 (Linux)

.../opt/conda/envs/dev/include/fmt/base.h:1089:48: error: 'back_inserter' was not declared in this scope; did you mean 'std::back_inserter'?
 1089 |   auto out() -> OutputIt { return back_inserter(container_); }
      |                                   ~~~~~~~~~~~~~^~~~~~~~~~~~
      |                                   std::back_inserter

Clang 18.1.8 (MacOS)

.../opt/conda/envs/dev/include/fmt/base.h:1089:35: error: use of undeclared identifier 'back_inserter'
 1089 |   auto out() -> OutputIt { return back_inserter(container_); }
      |

I can work around this by defining back_inserter in the global namespace before including any of the fmt headers.

@vitaut
Copy link
Contributor

vitaut commented Aug 8, 2024

I think we could add using namespace std; just before calling back_inserter which would handle both ADL and std::back_inserter case. Could you submit a PR?

@thraneh
Copy link
Author

thraneh commented Aug 8, 2024

I could submit a PR for that small change, but I'm lacking enough detailed knowledge about your library.

Clearly, you have a reason for preferring using namespace std; / back_inserter to simply using std::back_inserter.

In base.h there's a namespace adl which has invoke_back_inserter and otherwise does something similar to what you just suggested.

My problem is that an isolated PR with this small change just doesn't seem right. You have some idea behind the "adl" that I'm not familiar with.

@vitaut
Copy link
Contributor

vitaut commented Aug 9, 2024

invoke_back_inserter is irrelevant here but in any case this is fixed in bf870ae in a slightly simpler way.

@vitaut vitaut closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants