On 17/08/2015 01:29, Johannes Gerd Becker wrote:
>
> ...
>>>
>>> Why can I write
>>>
>>> using namespace std;
>>> auto i = begin (vec);
>>>
>>> everywhere in my code, yet not within a class that has a member functio=
n
>>> named begin ()?
>>>
>>> ...
>>>
>>
>> Doesn't the existing :: qualifier do this already:
>>
>> auto i == ::begin(vec); // ADL
>>
>> Or did I miss some unfortunate interaction with the way named namespaces
>> were formally added to the language?
>>
>>
> No, it doesn't.
>
> ::begin is considered as a qualified id, and ADL is not done for qualifie=
d
> ids ([basic.lookup.argdep], paragraph 1). ::begin will always only refer =
to
> the global namespace ([basic.lookup.qual], paragraph 4).
>
>
Just to expand your statements for clarity, you seem to be saying two of
the following three things:
1. Qualified ids such as Foo::Bar(7, 'A') and ::Bar(7, 'A') are not
looked up based on their argument types, thus greatly reducing the
ability to invoke overloaded functions????
2. Qualified ids such as Foo::Bar(7, 'A') and ::Bar(7, 'A') are not
searched outside their specified scope/namespace, even if an outer
scope/namespace provides a more appropriate overloaded function????
3. The Global Scope prefix :: operator also excludes any non-class
namespaces brought in via the using keyword, including the "std"
namespace????
#3 is the unfortunate interaction I alluded to in my previous post.
If you are saying just #2 and #3, I am a bit confused what the original
problem was:
A. Unqualified ids such as Bar(7, 'A') are not searched beyond the
first found scope containing an identifier Bar, even if that
identifier has the wrong type for its arguments.
B. Unqualified ids such as Bar(7, 'A') are not searched beyond the
first found scope containing an identifier Bar, even if that
identifier has the wrong type for its arguments, but only if that
first found scope is a class declaration.
C. Limitation A or B applies only to some language implementations or
to some editions of the standard.
In either case, I am still wondering why the exemplified issue cannot be
handled directly with a Qualified Id, specifically which (2 or more) scopes
do you want the template implementation to search for identifier begin().
Enjoy
Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.
https://www.wisemo.com
Transformervej 29, 2860 S=C3=B8borg, Denmark. Direct
+45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded