<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 4, 2015 at 12:26 PM, guoqing zhang <span dir="ltr"><<a href="mailto:gqzhang81@gmail.com" target="_blank">gqzhang81@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi ,<div><br></div><div>Can somebody explain why I need "typename" before Y<alignof(X)>::type  in the following piece of code ? </div><div><br></div><div><div>template<int N> struct Y { typedef int type; };</div><div><br></div><div>template<int N> void h() {</div><div>      struct  X {}; </div><div>      typename Y<alignof(X)>::type z;</div><div>}</div></div><div><br></div><div>Y<alignof(X)>::type is non-dependent, isn't it ?</div></div></blockquote><div><br></div><div>X is a dependent type [*], so alignof(X) is value-dependent [**], so Y<alignof(X)> is a dependent type, so you need typename. </div><div><br></div><div>[*] This is currently under discussion in CWG; the outcome seems likely to be that X is treated as a member of the current instantiation.</div><div>[**] 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.</div></div></div></div>