According to the standard [class] / 2:
... The class name is also inserted into the scope of the class itself; this is known as the name of the introduced class ...
In addition, [basic.scope.pdecl] / 9:
The declaration point for the name class entered (section 9) immediately follows the opening bracket of the class definition.
Finally, [basic.lookup.classref] / 3 and its example:
If unqualified-id is a type name, the type name is looked up ...
struct A { }; struct B { struct A { }; void f(::A* a); }; void B::f(::A* a) { a-> ~ A();
So far, we can collect:
- Within class A, there is a name A.
- This name is declared when you open the class A bracket definition.
- This name names the type.
If the above is correct, then why the following code cannot be compiled (in MSVC2015):
struct inj {}; typedef struct inj::inj inj2;
Error message
Error C2039 '{ctor}': is not a member of 'inj'
does not seem to conform to the standard:
Note. For example, the constructor is not an acceptable search result in the specified type specifier, therefore the constructor will not be used in place on behalf of the introduced class. -end note
source share