It says in C++ 3.3.7.2 [basic.scope.class]
A name
N
used in a classS
shall refer to the same declaration in its context and when re-evaluated in the completed scope ofS
.
What is an example of a translation unit where a name N
used in a class S
refers to a different declaration in its context than when it is re-evaluated in the completed scope of S
?
struct X {};
struct Y {};
typedef X N;
struct S
{
N n;
typedef Y N;
};
$ g++ test.cpp
9:15: error: declaration of ‘typedef struct Y S::N’ [-fpermissive]
4:11: error: changes meaning of ‘N’ from ‘typedef struct X N’ [-fpermissive]
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