Boost logo

Boost :

Subject: Re: [boost] [function] "paranoia" vs efficiency
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-10-02 12:08:32


Domagoj Saric wrote:
> As far as I can see boost::function<>::operator() performs:
> if (this->empty())
> boost::throw_exception(bad_function_call());
> before invoking the stored function (object)...
> My question is why or why only this "checked"/"safe" approach/method of
> invocation exists?

I think this branching can be effectively elided without sacrificing
safety if boost::function maintains never-empty internal guarantee. IOW,
if function::empty() returns true, then the function object is actually
pointing to some private function that simply throws upon being invoked.


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