Subject: Re: [boost] [ptr_container] Questionable strong guarantee of ptr_map::insert()
From: Kazutoshi Satoda (k_satoda_at_[hidden])
Date: 2009-09-05 12:33:31
Thorsten Ottosen wrote:
> Kazutoshi Satoda skrev:
>> Do you think passing a temporary auto_ptr should be allowed to allow
>> passing a returned auto_ptr?
> Oh yes. Generic libraries in particular needs to be useable rather than
(Sorry for this late response.)
I understood dropping pass-by-value version will decrease the usability
in the case where returning auto_ptr from a function and passing another
argument as rvalue. But I think it can be justified for the
exception-safety as more important aspect, as the FAQ currently says for
On the other hand, I don't see what the problem is about the term
"over-encapsulated". Could you please explain more about the concrete
problem with it?
> If there is a real need for operations with the strong guarantee, I
> think we should add them with the following signature:
> strong_push_back( std::auto_ptr<U>&, ... );
> albeit they can be implemeted by a user because you have access to the
> underlying container with .base():
> std::auto_ptr<U> ptr( ... );
> cont.base().push_back( ptr.get() );
I didn't know about the base() function. My original motivation can be
satisfied with the latter workaround. Thank you.
However, I still think providing the strong guaranteed version as the
default is better in general.
For function calls passing a single argument like push_back(), calling
like push_back(returning_auto_ptr(...).release()) seems no-less usable
and more expressive about what is happening.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk