remove_pointer type trait metafunction and smart pointers

Currently (afaict) there isnt a specialization of remove_pointer that handles smart pointers. Providing a very generic specialization: template <typename T, template<typename> class Ptr> struct remove_pointer<Ptr<T> >; or a set of specializations that cover shared_ptr etc + auto_ptr explicitly, "seems" like a rational extension. Are there any potential problems, and if not can we get this added to type traits?

Jeff Mirwaisi <jeff_mirwaisi@yahoo.com> writes:
Currently (afaict) there isnt a specialization of remove_pointer that handles smart pointers.
Providing a very generic specialization:
template <typename T, template<typename> class Ptr> struct remove_pointer<Ptr<T> >;
or a set of specializations that cover shared_ptr etc + auto_ptr explicitly, "seems" like a rational extension.
Are there any potential problems, and if not can we get this added to type traits?
That could break reams of code, and I would try very hard to stop it from happening. The type traits operate on _fundamental_ type properties as given by the C++ type system. A smart pointer type is not a pointer type; it is a class. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

Jeff Mirwaisi <jeff_mirwaisi@yahoo.com> writes:
Currently (afaict) there isnt a specialization of remove_pointer that handles smart pointers.
Providing a very generic specialization:
template <typename T, template<typename> class Ptr> struct remove_pointer<Ptr<T> >;
or a set of specializations that cover shared_ptr etc + auto_ptr explicitly, "seems" like a rational extension.
Are there any potential problems, and if not can we get this added to type traits?
Aside from what I said earlier about opposing this, please see boost/pointee.hpp, which I think does what you want. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Jeff Mirwaisi