$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2006-10-25 20:31:38
OK, add reinterpret_pointer_cast (I don't see why not, we need 
reinterpret_pointer_cast for the same reasons we need reinterpret_cast) to 
my request list, but the aliasing request is different: it doesn't simply 
treat a shared_ptr<T> as a shared_ptr<Y>.
What I need is a shared_ptr constructor, which takes a shared_ptr and a raw 
pointer, and returns a shared_ptr of the type of the raw pointer which 
points the same object the raw pointer points, but shares ownership (the 
"pn" member of shared_ptr) with the original shared_ptr:
template <class T>
shared_ptr
{
    ....
    template <class Y>
    shared_ptr( shared_ptr<Y> const & sp, T * p ): px(p), pn(sp.pn)
    {
    }
    ....
};
It may be a good idea to make this constructor private, and to call it from 
a friend namespace-scope function with a name which clearly indicates what's 
going on:
template <class T,class Y>
shared_ptr<T> some_really_descriptive_name( shared_ptr<Y> const & sp, T * 
p );
--Emil Dotchevski
----- Original Message ----- 
From: "Joe Gottman" <jgottman_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, October 25, 2006 5:06 PM
Subject: Re: [boost] shared_ptr feature request
>
> "Emil Dotchevski" <emildotchevski_at_[hidden]> wrote in message 
> news:BAY102-DAV10CB89F05952821C9EE4CBD4060_at_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
>
>
> _______________________________________________
> Unsubscribe & other changes: 
> http://listarchives.boost.org/mailman/listinfo.cgi/boost
>