type trait
- [remove_reference]
点击查看代码
#include<iostream>
using namespace std;
template<typename Tp>
class remove_ref {
public:
typedef Tp type;
};
template<typename Tp>
class remove_ref<Tp&> {
public:
typedef Tp type;
};
void test(int ¶m) {
//解除了引用
remove_ref<int&>::type p = param;
p = 100000000;
cout << "param = " << param<< endl;
}
int main() {
int a = 3;
// sucess to remove reference
test(a);
cout << "a = " << a << endl;
return 0;
}