Boost logo

Boost :

Subject: Re: [boost] [ptr_container] Questionable strong guarantee of ptr_map::insert()
From: David Abrahams (dave_at_[hidden])
Date: 2009-08-18 02:54:12

on Mon Aug 17 2009, Kazutoshi Satoda <> wrote:

> Hi,
> With current implementation of ptr_map::insert(), if an exception is
> thrown, the objected pointed by the passed pointer is deleted. Is this
> really providing strong guarantee as documented?
> I understand strong guarantee as described here.
>> The strong guarantee: that the operation has either completed
>> successfully or thrown an exception, leaving the program state exactly
>> as it was before the operation started.
> I think ptr_map::insert() doesn't provide this guarantee because
> deleting the object is a change of the program state.

You are correct.

I think the implementation of ptr_map::insert is probably as correct as
can be in doing that deletion (i.e. the docs are wrong, not the
implementation), but if I had written ptr_map I'd have given it an
auto_ptr parameter instead.

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at