Boost logo

Boost :

Subject: Re: [boost] [function] function wrapping and exception safety recap
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-10-11 13:45:42


On Mon, Oct 11, 2010 at 2:49 AM, Nevin Liber <nevin_at_[hidden]> wrote:
> On 11 October 2010 00:01, Emil Dotchevski <emil_at_[hidden]> wrote:
>> On Sat, Oct 9, 2010 at 12:38 PM, Daniel Walker
>> <daniel.j.walker_at_[hidden]> wrote:
>>> Finally, there have been suggestions to alter boost::function's
>>> exception safety guarantee directly through either policies or
>>> constructor options.
>>
>> We used to have an Allocator parameter to the boost::function template
>> and it was removed (just in time for this change to also be reflected
>> in C++0x) to reduce coupling.
>
> So what exactly is the proposed behavior if the function object cannot
> fit in the small object optimization space of unsafe_function and the
> allocation fails?

As proposed, unsafe_function has the same semantics as boost::function
with one (and only one) exception: the behavior of operator() is
undefined when it has no target. (The patch includes documentation for
this, though it may be difficult to read unless you generate the
HTML.) So, with respect to small object allocation, it behaves the
same as boost::function. After a failed allocation, the wrapper has no
target and future calls to operator bool() and empty() will return
false.

Daniel Walker


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