
"Emil Dotchevski" <emildotchevski@hotmail.com> wrote in message news:BAY102-DAV10CB89F05952821C9EE4CBD4060@phx.gbl...
I think it would be useful to add the following features to shared_ptr:
1. Support for aliasing: if I have a shared_ptr<T> pt, to get a shared_ptr<Y> py (where T and Y are possibly unrelated types) such that pt and py share ownership. For example, if T is an array of elements of type Y, with this feature pointing an element from the array through a shared_ptr<Y> would keep the entire array afloat. Similar example is being able to point through a shared_ptr<Y> to a member of an object of class T, which would keep the entire T object afloat.
We currently have static_pointer_cast, dynamic_pointer_cast, and const_pointer_cast, which, naturally enough, perform static_cast, dynamic_cast, and const_cast on the underlying pointer. What you are asking for is basically a reinterpret_pointer_cast. If you can give a use case it seems natural enough. Joe Gottman