Boost logo

Boost :

Subject: Re: [boost] [ptr_container] Questionable strong guarantee of ptr_map::insert()
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-08-24 07:52:11


Kazutoshi Satoda skrev:
> Thorsten Ottosen wrote:
>> Kazutoshi Satoda skrev:
>>> 1. (Type: Bugs)
>>> False strong guarantee in ptr_container documentation
>>
>> Right, it should be replaced with the basic guarantee and a note
>> saying the object is deleted when an exception is thrown.
>
> Putting "basic guarantee" seems over relaxing. One should be able to
> assume the contents of the container are unchanged when an exception is
> thrown.
>
> I propose the wording like this; "When an exception is thrown, nothing
> happens except performing delete x."
>
>>> 2. (Type: Feature Requests)
>>> Provide strong guaranteed overloads in ptr_container
>>
>> Hm. Do you propose to break the existing interface?
>
> Yes, I personally believe that the following use should be banned by
> design.
>>> map.insert(some_key(...), std::auto_ptr<value>(new value));
>
> And I agree with this practice.
>> People need to initialize smart pointers in seperate statements.
>
> I want to hear about some compatibility policy in Boost to guess the
> possibility of this kind of breaking (but otherwise good) changes.

Well, you also break perfectly valid and safe code where the auto
pointer is returned from a function.

What we could do instead is to either overload (if it does not lead to
ambiguities) or provide new versions of

strong_push_back()
strong_push_front()
strong_insert()
...

with the strong guarantee. My tests show that overloading does lead to
ambiguities. So we need to add new functions.

-Thorsten


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