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

Qualifying std::move, std::forward, etc. is unnecessary #431

Closed
StephanTLavavej opened this issue Jan 21, 2015 · 4 comments · Fixed by #1085
Closed

Qualifying std::move, std::forward, etc. is unnecessary #431

StephanTLavavej opened this issue Jan 21, 2015 · 4 comments · Fixed by #1085
Assignees

Comments

@StephanTLavavej
Copy link
Contributor

Library Standardese almost universally qualifies std::move and std::forward. It occasionally qualifies other things, like std::pair, std::is_constructible, etc. (especially in TR1-era stuff). All of this is unnecessary, due to 17.6.1.1 [contents]/3:

"Whenever a name x defined in the standard library is mentioned, the name x is assumed to be fully qualified as ::std::x, unless explicitly described otherwise. For example, if the Effects section for library function F is described as calling library function G, the function ::std::G is meant."

Observe how /3 correctly uses ::std:: (which is what implementers have to do, for functions where ADL is a concern) while the rest of the Library casually says std:: which isn't even correct. And the occurrences of std:: do not correspond to where implementers must defend against ADL - e.g. pair is never vulnerable (it's a class template, so implementers can say it unqualified), but equal() is, yet the Library qualifies std::pair but says equal() unqualified. Madness!

To avoid useless verbosity, I recommend relying on /3 to the greatest extent possible. The Library should eliminate all occurrences of std:: unless something is especially ambiguous to humans (in which case we should consider formally saying ::std::). Currently, I believe the only human-ambiguous cases are those where ADL is involved elsewhere - for example, because we rely on ADL swap in some places, it is good and desirable to say ::std::swap when we mean that.

This means that I disagree with #285, at least when it comes to saying std::raise. (A citation link whenever raise is mentioned would be entirely fine, though.)

@StephanTLavavej
Copy link
Contributor Author

In the LWG at Lenexa, there was widespread agreement that we should keep saying std::move (and maybe std::forward) in order to reinforce the message that it isn't a customization point. I'll buy that, but for everything else I'm still advocating dropping the qualification.

@jensmaurer
Copy link
Member

As far as #285 concerned, the core language has a different policy: It uses std::something to highlight that, in fact, the function defined in the standard library is meant, not some random user function that happens to have that name. Note that the general provision you cited is in the library front matter and therefore not supposed to apply to the core language section.

@jensmaurer
Copy link
Member

Stephan: What about examples of user-written code, e.g. in 30.6.8p8? Those examples are (obviously) not written inside "namespace std", so they become ill-formed when we drop the "std::".

@StephanTLavavej
Copy link
Contributor Author

Hmm. I agree that the Core clauses shouldn't be touched. I'd also be fine with not touching user examples like 30.6.8/8, although I consider that to be debatable - note that the example is obviously a snippet omitting #include <future> and could easily be omitting using namespace std; too.

jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 21, 2016
The standard library specifies that references to its names are assumed to be prefixed by '::std::'. Therefore, we can remove any explicit 'std::' prefixes.

[iterator.range] was not touched, because it is unclear whether argument-dependent lookup was intended to be disabled here.

Fixes cplusplus#431.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 21, 2016
The standard library specifies that references to its names are assumed to be prefixed by '::std::'. Therefore, we can remove any explicit 'std::' prefixes.

[iterator.range] was not touched, because it is unclear whether argument-dependent lookup was intended to be disabled here.

Fixes cplusplus#431.
@jensmaurer jensmaurer self-assigned this Nov 21, 2016
jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 21, 2016
The standard library specifies that references to its names are assumed to be prefixed by '::std::'. Therefore, we can remove any explicit 'std::' prefixes.

[iterator.range] was not touched, because it is unclear whether argument-dependent lookup was intended to be disabled here.

Fixes cplusplus#431.
jensmaurer added a commit to jensmaurer/draft that referenced this issue Nov 26, 2016
The standard library specifies that references to its names are assumed to be prefixed by '::std::'. Therefore, we can remove any explicit 'std::' prefixes.

[iterator.range] was not touched, because it is unclear whether argument-dependent lookup was intended to be disabled here.

Fixes cplusplus#431.
tkoeppe pushed a commit that referenced this issue Nov 26, 2016
The standard library specifies that references to its names are assumed to be prefixed by '::std::'. Therefore, we can remove any explicit 'std::' prefixes.

[iterator.range] was not touched, because it is unclear whether argument-dependent lookup was intended to be disabled here.

Fixes #431.
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

Successfully merging a pull request may close this issue.

2 participants