
On Sat, Oct 23, 2010 at 12:01 PM, Domagoj Saric <dsaritz@gmail.com> wrote:
"Edward Diener" <eldiener@tropicsoft.com> wrote in message news:i9tsoi$7m2$1@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