Boost logo

Boost :

From: me22 (me22.ca_at_[hidden])
Date: 2006-10-26 16:13:36


On 10/25/06, Emil Dotchevski <emildotchevski_at_[hidden]> wrote:
> 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>.
>
Do you have a use case for reinterpret_pointer_cast?

You don't need it to pass arbitrary shared_ptr<T>s into a function;
shared_ptr<void> works fine for that.

> 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:
>
Why do you want this? So it will delete both pointers?

The code you've given would, I expect, have some serious problems. I
think one of the pointers would get leaked and if it was the one from
the original shared_ptr that leaked, a wrong deleter could be called
on the new pointer.

~ SWMc


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk