Boost logo

Boost :

From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2002-06-13 11:02:01


> -----Original Message-----
> From: Peter Dimov [mailto:pdimov_at_[hidden]]
> From: "Alexander Terekhov" <alexander.terekhov_at_[hidden]>
> > > > explicit scoped_ptr(std::auto_ptr<T> &p): ptr(p.release()) {}
> > > >
> > > > and it works as expected, taking away ownership from
> auto_ptr and
> giving
> > > > it to scoped_ptr.
> > > >
> > > > Is this something my compiler (MSVC6SP5) allows as an
> extenstion?
> > >
> > > Yes, this is a Microsoft extension. VC 7 doesn't even warn. Odd.
> >
> > a) why not simply: explicit scoped_ptr(std::auto_ptr<T> p):
> ptr(p.release()) {} <?>
>
> Yes, this would work. :-)

Is it possible to have such a thing? I would want the ability to create something (such as a thread). In the client I would have a scoped_ptr around the thread class so that it joins() and exits as necessary. However in the creation function I'd want to return auto_ptr to maintain the pointer during the passing from the creation function to the scoped_ptr. Using a scoped_ptr/auto_ptr is more specific of what I want to do than just using shared_ptr.


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