
Ion GaztaƱaga wrote: [...]
While developing pointer-independent code, however, I've seen that some features are present in boost (for example, get_pointer() function) and other features are missing, and I would like to propose them:
1. Overloads of static_pointer_cast, dynamic_pointer_cast, const_pointer_cast overloads for raw pointers, so that we can use pointer_xxx_cast in a generic way.
Makes sense. :-) boost/utility/pointer_cast.hpp, probably.
2. Add reinterpret_pointer_cast to complete cast family.
Out of curiosity, why do you want it?
3. A protocol to obtain a pointer of the same type from any pointer. For example, if you want to generically use a pointer (for example, raw or relative pointer) in a class and you want to declare another pointer to other type (raw or relative, depending on the source):
//typedef typename boost::pointer_to_other //<GenericPointer, NewType>::type MyNewPointer;
//A new pointer to float values typedef typename boost::pointer_to_other <SmartPtr, float>::type MyFloatPointer;
We should define how this protocol is implemented in boost smart pointers (for example, using overloading or a STL-like rebind mechanism) so that every boost smart pointer developer knows how to make its pointer type protocol-aware.
template<class T, class U, template<class> class Sp> class pointer_to_other< Sp<T>, U > { typedef Sp<U> type; }; works with auto_ptr and all boost smart pointers. Other smart pointers may want to specialize pointer_to_other.