templates

Pointers and recursive templates

How do you get the 'pointed-to' type in C++?

template<typename T>
struct RemovePointer
{
    typedef T value_type;
};

template<typename T>
struct RemovePointer<T*>
{
    typedef typename RemovePointer<T>::value_type value_type;
};

What's the point? With a bit of boost magic, you can use pointers transparently in generic code:

Syndicate content