<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content=IE=5 http-equiv=X-UA-Compatible>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
TD {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
LI {
        MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN-TOP: 5px
}
BODY {
        FONT-SIZE: 9pt; FONT-FAMILY: Arial, arial; MARGIN: 10px; LINE-HEIGHT: 1.4
}
</STYLE>

<META name=GENERATOR content=ActiveSquare></HEAD>
<BODY>
<P> </P>
<P>Hi all,</P>
<P> </P>
<DIV>Note - this is with respect to C++ 03.</DIV>
<DIV></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM>Test code:</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM>template <int> struct A {};<BR>int const i = {42};<BR>typedef A<i> Ai;</EM></DIV>
<DIV><EM><BR> </EM></DIV>
<DIV>For non-type template argument, standard (C++ 03) says that: </DIV>
<DIV></DIV>
<DIV><EM>14.3.2 / 1</EM></DIV>
<P><EM>A template-argument for a non-type, non-template template-parameter shall be one of:</EM></P>
<UL><EM></EM>
<LI><EM>an <STRONG>integral constant-expression</STRONG> of integral or enumeration type; or ......</EM></LI></UL>
<DIV>For the test code above, the statement '<EM>typedef A<i> Ai</EM>', should the compiler </DIV>
<DIV>check the rhs (rvalue) of variable 'i' to determine if it is a constant or not?</DIV>
<DIV>Shouldnt it just check the type of i (which is declared as const)? </DIV>
<DIV>Whether 'i' evaluates to constant (at compile time) or not should be the responsibility of compiler </DIV>
<DIV>while processing statement '<EM>int const i = {42}</EM>' and not '<EM>typedef A<i> Ai' ? Isnt it?</EM></DIV>
<DIV> </DIV>
<DIV>Another analogy:<BR>For arrays, the size of the array needs to be a compile time constant. So, the following code :</DIV>
<DIV></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM>int const x = 42; </EM></DIV>
<DIV><EM>int z[x];</EM></DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV>For the statement <EM>'int z[x]'</EM>, will the compiler evaluate the rhs of <EM>'x'</EM> to check if it evaluates to constant at runtime </DIV>
<DIV>or will it just see that '<EM>x</EM>' is of 'integer const' type and hence there is no problem with the array declaration? </DIV>
<DIV>Whether '<EM>x</EM>' evaluates to constant should be the responsibility of compiler while processing statement '<EM>int const x=42</EM>'</DIV>
<DIV>and not while processing '<EM>int z[x]</EM>' ?</DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV>Should this analogy be applicable to non-type template argument?</DIV>
<DIV></DIV>
<P>Please throw some light on this, am I missing any particular case?</P>
<P> </P>
<P>Thanks,</P>
<P>Rahul</P></X-BODY></X-BODY></X-BODY></X-BODY>
<P> </P>
<P> </P><!--SP:rahul1.jain--><!--rahul1.jain:EP-->
<P> </P>
<TABLE id=confidentialsignimg>
<TBODY>
<TR>
<TD namo_lock="">
<P><IMG border=0 src="cid:XOK0LK7CT9SZ@namo.co.kr" width=520></P></TD></TR></TBODY></TABLE></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=138117183f8501de75262b4a003fec11cf86836f58469129e56225dd835e375fc400edea8930898a434c6ebf74e200ff220d3e02ce1cb961d6250c6ef56fc7aacf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'>