Boost logo

Boost :

Subject: Re: [boost] [function] function wrapping with noexceptionsafetyguarantee
From: Emil Dotchevski (emil_at_[hidden])
Date: 2010-10-23 15:27:16


On Sat, Oct 23, 2010 at 12:01 PM, Domagoj Saric <dsaritz_at_[hidden]> wrote:
>
> "Edward Diener" <eldiener_at_[hidden]> wrote in message
> news:i9tsoi$7m2$1_at_dough.gmane.org...
>
>> I do not understand why others are upset that invoking boost::function on
>> an empty target should throw an exception. It is equivalent in my mind to
>> calling a function through a function pointer which is null.
>
> Short recap of some of the problems (with the current implementation) WRT to
> the throw-on-empty issue:
> - the way the throwing is implemented is inefficient (both in terms of speed
> and template code bloat)
> - the check and throwing may be entirely redundant if the calling code
> already checks/ensures that it does not call an empty function

As pointed out, the check can be removed. We're waiting for someone
who cares about the current inefficiency of the check to remove it
instead of arguing. :)

> - there is no way to choose a different on-empty behaviour

You're missing the point I believe Edward is making. Throwing an
exception when an empty function is called is a valid behavior in case
the on-empty behavior is undefined (don't call empty functions if you
don't want the exception.)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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