Boost C++ Libraries: Ticket #3705: Boost.Function FAQ https://svn.boost.org/trac10/ticket/3705 <p> From <a class="ext-link" href="http://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thread/f66ee6174fb04762/a5c99eadde5a1e52?rnum=1&amp;_done=/group/comp.lang.c%2B%2B.moderated/browse_frm/thread/f66ee6174fb04762/a5c99eadde5a1e52%3Ftvc%3D1%26#doc_b36422ac63363172"><span class="icon">​</span>http://groups.google.com/group/comp.lang.c++.moderated/tree/browse_frm/thread/f66ee6174fb04762/a5c99eadde5a1e52?rnum=1&amp;_done=/group/comp.lang.c%2B%2B.moderated/browse_frm/thread/f66ee6174fb04762/a5c99eadde5a1e52%3Ftvc%3D1%26#doc_b36422ac63363172</a> </p> <hr /> <p> Peter Dimov </p> <blockquote class="citation"> <p> On Dec 2, 7:18 am, Sebastian Hauer &lt;ha...@…&gt; 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 <a class="missing wiki">FastDelegate</a>. I also came across tr1::function which I was blissfully unaware of until now, considering that the original proposal was from late 2002 (see:http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1402.html). 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. </p> </blockquote> <p> 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.) </p> <hr /> <p> Please add this to Boost.Function FAQ. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3705 Trac 1.4.3 Daniel James Tue, 09 Mar 2010 08:11:59 GMT component changed https://svn.boost.org/trac10/ticket/3705#comment:1 https://svn.boost.org/trac10/ticket/3705#comment:1 <ul> <li><strong>component</strong> <span class="trac-field-old">Documentation</span> → <span class="trac-field-new">function</span> </li> </ul> Ticket Steven Watanabe Wed, 10 Mar 2010 21:36:21 GMT <link>https://svn.boost.org/trac10/ticket/3705#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3705#comment:2</guid> <description> <p> I don't think that this would be a good idea to add to the FAQ, given that boost::function does not work this way. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sun, 06 Jun 2010 23:12:03 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3705#comment:3 https://svn.boost.org/trac10/ticket/3705#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket