重点:
1.C++11提供了一个模板类std::decay,移除类型中的一些特性,比如引用、常量、volatile,但是不包括指针特性。
template<typename T>
void printT(T arg)
{
if (is_same_v<decay_t<T>,int>)
{
cout << "same type" << endl;
}
else
{
cout << "not same type" << endl;
}
}
int main()
{
int temp = 1;
int& num = temp;
const int* test = &temp;
printT(temp);
printT(&temp);
printT(num);
printT(test);
return 0;
}