Boost C++ Libraries: Ticket #2319: function::operator= should "move", copy assignment should have by-value argument https://svn.boost.org/trac10/ticket/2319 <p> A few days ago, I added a comment to ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1910" title="#1910: Bugs: function::swap should avoid doing memory allocations (closed: fixed)">#1910</a> (regarding function::swap), suggesting to have boost::function's assignment operators calling its new <em>move_assign</em> member function, instead of calling <em>swap</em>. Doing so would significantly improve its performance. </p> <p> Now I think that function::operator= deserves its own ticket, especially because the <em>copy assignment</em> of boost::function can be improved even more, by having its argument passed <em>by value</em>, instead of creating a copy of the argument inside the body of the function. Doing so would allow the compiler to do copy elision, when its argument is an rvalue. See also <a class="ext-link" href="http://lists.boost.org/Archives/boost/2008/09/142106.php"><span class="icon">​</span>Improving the assignment operators of various Boost types</a> </p> <p> So please consider the attached patch. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2319 Trac 1.4.3 niels_dekker Thu, 11 Sep 2008 16:11:51 GMT attachment set https://svn.boost.org/trac10/ticket/2319 https://svn.boost.org/trac10/ticket/2319 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">function_assignment.patch</span> </li> </ul> Ticket niels_dekker Thu, 11 Sep 2008 17:17:31 GMT severity changed https://svn.boost.org/trac10/ticket/2319#comment:1 https://svn.boost.org/trac10/ticket/2319#comment:1 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Optimization</span> </li> </ul> Ticket Antony Polukhin Wed, 05 Sep 2012 20:28:52 GMT <link>https://svn.boost.org/trac10/ticket/2319#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2319#comment:2</guid> <description> <p> Your patch adds memory leaks for cases, when function is already initialized with big functional object (move_assign member function does not call clean()). </p> </description> <category>Ticket</category> </item> </channel> </rss>