Foot note (33) in page 53 of N4140:
Lookups in which function names are ignored include names appearing in a nested-name-specifier, an elaborated-type-specifier, or a base-specifier.
namespace A
{
void std();
void foo()
{
std::cout << "Hello World"; // (1)
}
};
In (1), std
cannot name a function, thus the function A::std
is ignored during lookup, and the code compiles.
This rule is explicitly mentioned in [basic.lookup.qual]/1:
If a
::
scope resolution operator in a nested-name-specifier is not preceded by a decltype-specifier, lookup of the name preceding that::
considers only namespaces, types, and templates whose specializations are types.
Another example from the list includes
class A : B {};
Here, B
cannot designate a function, thus any functions called B
are ignored during lookup. Same goes for
class A a;
Where A
cannot name a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With