
8 Oct
2010
8 Oct
'10
1:22 a.m.
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.