D
DaKoadMunky
<CODE>
template<int N>
int ReturnN()
{
return N;
}
int anInt = 32;
int main()
{
ReturnN<16>();
ReturnN<anInt>();
return 0;
}
</CODE>
The code above compiles using VC++.NET 7.00.9466.
It fails to compile using the online compiler at
www.comeaucomputing.com/tryitout (default settings with target of Windows XP)
with the following message...
<ERROR>
"ComeauTest.c", line 13: error: expression must have a constant value
ReturnN<anInt>();
^
1 error detected in the compilation of "ComeauTest.c".
</ERROR>
Can anyone tell me which compiler is correct?
I assume it is Comeau, but you never know.
FYI...The VC++.NET program does produce correct results. The version of the
function invoked by "ReturnN<anInt>()" instead of returning a hardcoded value
actually returns the result of dereferencing a hardcoded address (in this case
the address of the global variable anInt.)
Thanks.
template<int N>
int ReturnN()
{
return N;
}
int anInt = 32;
int main()
{
ReturnN<16>();
ReturnN<anInt>();
return 0;
}
</CODE>
The code above compiles using VC++.NET 7.00.9466.
It fails to compile using the online compiler at
www.comeaucomputing.com/tryitout (default settings with target of Windows XP)
with the following message...
<ERROR>
"ComeauTest.c", line 13: error: expression must have a constant value
ReturnN<anInt>();
^
1 error detected in the compilation of "ComeauTest.c".
</ERROR>
Can anyone tell me which compiler is correct?
I assume it is Comeau, but you never know.
FYI...The VC++.NET program does produce correct results. The version of the
function invoked by "ReturnN<anInt>()" instead of returning a hardcoded value
actually returns the result of dereferencing a hardcoded address (in this case
the address of the global variable anInt.)
Thanks.