Boost C++ Libraries: Ticket #1067: Function needs to use pass-by-reference internally https://svn.boost.org/trac10/ticket/1067 <p> Boost.Function uses pass-by-value internally for the function object. While it is unspecified how many times the function object would be copied, we should still minimize this amount. The following code snippet illustrates how many copy constructions are performed. </p> <p> struct Functor { </p> <blockquote> <p> Functor(void) </p> <blockquote> <p> { std::cout &lt;&lt; "Functor constructor (" &lt;&lt; this &lt;&lt; ')' &lt;&lt; std::endl; } </p> </blockquote> <p> Functor(const Functor&amp;) </p> <blockquote> <p> { std::cout &lt;&lt; "Functor copy constructor (" &lt;&lt; this &lt;&lt; ')' &lt;&lt; std::endl; } </p> </blockquote> <p> ~Functor(void) </p> <blockquote> <p> { std::cout &lt;&lt; "Functor destructor (" &lt;&lt; this &lt;&lt; ')' &lt;&lt; std::endl; } </p> </blockquote> </blockquote> <blockquote> <p> void operator()(void) const </p> <blockquote> <p> { std::cout &lt;&lt; "Hello world!" &lt;&lt; std::endl; } </p> </blockquote> </blockquote> <blockquote> <p> std::string memfunc(void) const </p> <blockquote> <p> { return std::string("hello world!!!!!!"); } </p> </blockquote> </blockquote> <p> }; </p> <p> int main(void) { </p> <blockquote> <p> Functor func; boost::function0&lt;void&gt; f(func); </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1067 Trac 1.4.3 Douglas Gregor Fri, 06 Jul 2007 16:02:49 GMT status changed https://svn.boost.org/trac10/ticket/1067#comment:1 https://svn.boost.org/trac10/ticket/1067#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Marshall Clow Thu, 12 Jul 2007 15:17:56 GMT owner, status changed https://svn.boost.org/trac10/ticket/1067#comment:2 https://svn.boost.org/trac10/ticket/1067#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Douglas Gregor</span> to <span class="trac-author">doug_gregor</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> </ul> <p> Assigned to "doug_gregor" instead of nonexistent user "dgregor" </p> Ticket Tarjei Knapstad <tarjei.knapstad@…> Wed, 18 Jul 2007 08:05:31 GMT attachment set https://svn.boost.org/trac10/ticket/1067 https://svn.boost.org/trac10/ticket/1067 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boostfunction.cpp</span> </li> </ul> <p> Ready-to-run example code </p> Ticket Douglas Gregor Thu, 13 Sep 2007 18:26:04 GMT owner, status changed https://svn.boost.org/trac10/ticket/1067#comment:3 https://svn.boost.org/trac10/ticket/1067#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">doug_gregor</span> to <span class="trac-author">Douglas Gregor</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Douglas Gregor Thu, 13 Sep 2007 19:06:54 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1067#comment:4 https://svn.boost.org/trac10/ticket/1067#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/39244" title="function_template.hpp: - Pass-by-reference internally, when we can. ...">[39244]</a>) function_template.hpp: </p> <ul><li>Pass-by-reference internally, when we can. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1067" title="#1067: Bugs: Function needs to use pass-by-reference internally (closed: fixed)">#1067</a> </li></ul> Ticket