[Boost-bugs] [Boost C++ Libraries] #3705: Boost.Function FAQ

Subject: [Boost-bugs] [Boost C++ Libraries] #3705: Boost.Function FAQ
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-12-03 08:03:44

#3705: Boost.Function FAQ
 Reporter: anonymous | Owner: dgregor
     Type: Feature Requests | Status: new
Milestone: Boost 1.42.0 | Component: Documentation
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |


 Peter Dimov
> On Dec 2, 7:18 am, Sebastian Hauer <ha..._at_[hidden]> wrote:
> Hi,
> Recently I had the need for an efficient polymorphic function wrapper
> (aka delegate), so I looked at a few possible options such as
> boost::function and FastDelegate. I also came across tr1::function
> which I was blissfully unaware of until now, considering that the
> original proposal was from late 2002
> While reading the proposal I noticed that a tr1::function can throw a
> bad_function_call exception if no target was assigned.
> I was just wondering for the rationale behind this design decision.
> In my opinion the fact that it throws goes against C++'s notion
> of "you only pay for what you use".
> I'm interested in hearing what your thoughts are on this.

 This behavior doesn't need to impose a cost. An std::function (it's
 officially in C++0x) that hasn't been assigned a target may internally
 store a target function that throws bad_function_call. It need not
 test on every call (even though the test wouldn't impose much overhead
 compared to the indirect call that follows.)


 Please add this to Boost.Function FAQ.

Ticket URL: <https://svn.boost.org/trac/boost/ticket/3705>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC