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 &param) {
    //解除了引用
    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;
}
- [is_intergal]
posted @ 2022-07-24 18:18  locker_10086  阅读(18)  评论(0编辑  收藏  举报