<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 6, 2015 at 12:55 AM, 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 Richard,<div><br></div><div>So X is a dependent type  ? which of the following categories X belongs to ?</div></div></blockquote><div><br></div><div>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).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><ul style="line-height:1.5em;list-style-type:square;margin:0.3em 0px 0.5em 1.6em;padding:0px;color:rgb(0,0,0);font-family:DejaVuSans,'DejaVu Sans',arial,sans-serif;font-size:12.8000001907349px"><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">template parameter</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">a member of an <i>unknown specialization</i> (see below)</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">a nested class/enum that is a dependent member of <i>unknown specialization</i> (see below)</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">a cv-qualified version of a dependent type</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">a compound type constructed from a dependent type</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">an array type constructed from a dependent type, or whose size is a value-dependent constant expression (see below)</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">a template-id where either the template name is a template parameter, or any of template arguments is type- or value-dependent</li><li style="margin-bottom:0.1em;line-height:1.2em;margin-top:0.3em">the result of <a href="http://en.cppreference.com/w/cpp/language/decltype" title="cpp/language/decltype" style="text-decoration:none;color:rgb(11,0,128);background:none" target="_blank">decltype</a> applied to a type-dependent expression </li></ul><div><font color="#000000" face="DejaVuSans, DejaVu Sans, arial, sans-serif"><span style="font-size:12.8000001907349px;line-height:15.3600006103516px">(copied from <a href="http://cppreference.com" target="_blank">cppreference.com</a>)</span></font></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards</div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">-guoqing</div></font></span><div><div class="h5"><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 12:12 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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></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>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>