
On Thu, Oct 7, 2010 at 7:56 PM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Thu, Oct 7, 2010 at 8:37 PM, Emil Dotchevski <emil@revergestudios.com> wrote:
On Thu, Oct 7, 2010 at 6:22 PM, Peter Dimov <pdimov@pdimov.com> wrote:
Daniel Walker wrote:
void do_stuff(boost::function<int(int)> f) { // ... if(f) { // Remove the exception safety guarantee for this block. boost::unsafe_function<int(int)> g = f; for(int i = 0; i < INT_MAX; ++i) g(i); } // ... }
This example implies that unsafe_function is inherently more efficient, but this need not be so. An empty function may point to throw_bad_function_call instead of NULL.
Right, and what the empty boost::function does needs not be decided at compile time, it can be done in the constructor.
However the empty built-in Boost.Function still does an if(isnull) test on every operator call, whether you assigned something in the constructor or not...
Like Peter said, this need not be the case. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode