
27 Feb
2010
27 Feb
'10
5:45 a.m.
AMDG OvermindDL1 wrote:
Actually, the only reason they outperform boost::function is because boost::function adds in extra assembly code for a comparison check (to null, if true it throws an exception). If that is removed (perhaps by a policy, I certainly know that most of my function would never be empty, would even be nice if the function defaulted to an empty function if empty instead), then boost::function becomes even faster. I have actually started to take a liking to Boost.Variant for function callbacks (if I know what they can be), it inlines it and the function pointer call disappears. :)
The comparison could be removed even without a policy by using the null object pattern. In Christ, Steven Watanabe