Hi All,
Can you please help me to understand why the following code is behaving this way?
I think both outputs should be 1 ( 1 means const T), but its not!!
template <typename T>
struct IsConst{
enum {isConst = 0};
};
template <typename T>
struct IsConst<const T>{
enum {isConst = 1};
};
template <typename T>
void print(T val){
cout << IsConst<T>::isConst << endl; //prints 0
}
int main() {
const int x = 10;
print(x); //why dynamic argument deduction deducting it as normal integer?
cout << IsConst<const int>::isConst << endl; //prints 1
return 0;
}
why dynamic argument deduction deducting it as normal integer?
Thanks in advance.
S.