Boost logo

Boost :

Subject: Re: [boost] [function] function wrapping with no exceptionsafetyguarantee
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-10-25 16:27:13

On Fri, Oct 22, 2010 at 3:39 PM, Emil Dotchevski
<emil_at_[hidden]> wrote:
> On Fri, Oct 22, 2010 at 10:35 AM, Daniel Walker
> <daniel.j.walker_at_[hidden]> wrote:
>> Oops. Sorry, I spoke too soon. In fact, it IS currently possible for a
>> boost::function object to become empty due to a failed assignment. It
>> happens because the small object manager clones the target during a
>> call to swap(). If there is an exception during the allocation,
>> boost::function handles it, sets itself to empty and rethrows.
> Unless you can find specific documentation for this behavior (I
> couldn't), you can't assume that op= will leave the target empty upon
> failure.

True, but my point is that it is _possible_ for operator= to leave
boost::function empty. So if we change how the current implementation
of boost::function enters the empty state, we need to take account of
this case.

> AFAIK it provides only basic exception safety, meaning the
> state of the target is unspecified upon failure except that no memory
> will leak.

Changing boost::function's internal vtable from null to a static
"empty" vtable will not change the exception safety of any of its
member functions. However, it will increase the space overhead in the
data segment.

Daniel Walker

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