boost 提供了 remove_pointer ,不过不够,有的时候我们需要拿掉一个“指向指针的指针……的指针”类型上面所有的“指针”前缀,所以下面这个 remove_all_pointer 就有用了,当然它还很不完善,这里先备份,慢慢修改:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace boost;
template
struct remove_all_pointer
{
typedef T type;
};
template
struct remove_all_pointer
{
typedef typename remove_all_pointer::type type;
};
看来是非常容易,测试呢:
#include
#include
#include "remove_all_pointer.hpp"
int main()
{
typedef remove_all_pointer::type result;
cout << typeid(result).name() << endl;
typedef remove_pointer::type res1;
cout << typeid(res1).name() << endl;
cin.get();
}
结果不用我说了。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace boost;
template
struct remove_all_pointer
{
typedef T type;
};
template
struct remove_all_pointer
{
typedef typename remove_all_pointer::type type;
};
看来是非常容易,测试呢:
#include
#include
#include "remove_all_pointer.hpp"
int main()
{
typedef remove_all_pointer::type result;
cout << typeid(result).name() << endl;
typedef remove_pointer::type res1;
cout << typeid(res1).name() << endl;
cin.get();
}
结果不用我说了。