Vladimir Grigoriev
2009-12-07 12:45:29 UTC
Let consider the function
template <typename T>
void check_const( T i )
{
++i;
}
If then it will be called such a way
check_const<const int>( 0 );
the compiler ( VC++ 2005 EE) issue the error
"error C3892: 'i' : you cannot assign to a variable that is const"
However if it will be called the following way
const int value = 0;
check_const( value );
the compiler does not issue the error.
Why does not the compiler issue the error in the second caase?
Vladimir Grigoriev
template <typename T>
void check_const( T i )
{
++i;
}
If then it will be called such a way
check_const<const int>( 0 );
the compiler ( VC++ 2005 EE) issue the error
"error C3892: 'i' : you cannot assign to a variable that is const"
However if it will be called the following way
const int value = 0;
check_const( value );
the compiler does not issue the error.
Why does not the compiler issue the error in the second caase?
Vladimir Grigoriev