dependent name related question

Hi ,

Can somebody explain why I need “typename” before Y<alignof(X)>::type in the following piece of code ?

template struct Y { typedef int type; };

template void h() {
struct X {};
typename Y<alignof(X)>::type z;
}

Y<alignof(X)>::type is non-dependent, isn’t it ?

Regards
-guoqing

X is a dependent type [*], so alignof(X) is value-dependent [**], so
Y<alignof(X)> is a dependent type, so you need typename.

[*] This is currently under discussion in CWG; the outcome seems likely to
be that X is treated as a member of the current instantiation.
[**] Even if X is a member of the current instantiation, sizeof(X) and
alignof(X) should be value-dependent; the current standard wording gets
this case wrong.

Hi Richard,

So X is a dependent type ? which of the following categories X belongs to ?

Hi Richard,

So X is a dependent type ? which of the following categories X belongs to
?

It's not listed here due to a bug in the standard, currently under
discussion by the C++ committee (see the [*] in my previous email).