c++ - Where in the Standard does it say that a member alias-declaration can be used as if it was a static member? -
consider following snippet:
#include <iostream> struct { int i; using int = int; }; int main() { std::cout << sizeof(a::int) << '\n'; } it compiles , executes in clang , gcc. know looks obvious, couldn't find in standard (c++14) supporting reference a::int in main().
this normal qualified lookup. [basic.lookup.qual]:
the name of class or namespace member or enumerator can referred after
::scope resolution operator (5.1) applied nested-name-specifier denotes class, namespace, or enumeration.
then [class.qual]:
if nested-name-specifier of qualified-id nominates class, name specified after nested-namespecifier looked in scope of class (10.2), except cases listed below. name shall represent 1 or more members of class or of 1 of base classes (clause 10). [ note: class member can referred using qualified-id @ point in potential scope (3.3.7). —end note ] exceptions name lookup rule above following:
- a destructor name [...]
- a conversion-type-id of conversion-function-id [...]
- the names in template-argument of template-id [...]
- the lookup name specified in using-declaration [...]
the nested-name-specifier in example a, class. none of exceptions apply. name, int, in scope of class.
from [dcl.typedef]:
a name declared
typedefspecifier becomes typedef-name. within scope of declaration, typedef-name syntactically equivalent keyword , names type associated identifier in way described in clause 8. typedef-name synonym type.
[...]
typedef-name can introduced alias-declaration. identifier following using keyword becomes typedef-name , optional attribute-specifier-seq following identifier appertains typedef-name. has same semantics if introducedtypedefspecifier.
so alias-declaration introduces name int scope of a, found according qualified lookup rules enumerated.
Comments
Post a Comment