$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-06-12 11:22:57
Peter Dimov wrote:
>
> From: "Markus Schöpflin" <markus.schoepflin_at_[hidden]>
[snip]
> > std::scoped_ptr<Obj> p(create_obj());
>
> No, unfortunately it will not. The constructor will take a non-const
> reference to auto_ptr, and those cannot be bound to rvalues. std::auto_ptr
> uses an interesting (and obscure) technique to allow
>
Hmm, I just hacked my copy of scoped_ptr.hpp and added
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?
> std::auto_ptr<Obj> p(create_obj());
>
> and I'm not sure that we need to enable this functionality for scoped_ptr.
Well, it would make the intention clear that I want to take ownership
of the generated object and keep it.
OTOH, it works if you write
std::scoped_ptr<Obj> p(create_obj().release());
but it looks su much nicer if you can ommit the release()... :-)
Markus