Neil Kirk Neil Kirk - 2 months ago 14
C++ Question

Can std::remove_pointer be used to remove all indirection from pointer type?

Say that I have.. int, int*, int**, etc. Can I use std::remove_pointer or similar to get straight to type int? Thanks

Answer

Yuppers.

template<typename T> struct remove_all {
    typedef T type;
};
template<typename T> struct remove_all<T*> {
    typedef typename remove_all<T>::type type;
};

std::remove_pointer itself isn't of that much use here.