
on Mon Aug 17 2009, Kazutoshi Satoda <k_satoda-AT-f2.dion.ne.jp> 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. http://www.boost.org/community/exception_safety.html
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 http://www.boostpro.com