Boost C++ Libraries: Ticket #2849: function_equal should work with binds holding weak_ptr values https://svn.boost.org/trac10/ticket/2849 <p> <a class="ext-link" href="http://lists.boost.org/Archives/boost/2008/07/139970.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2008/07/139970.php</a> </p> <p> To fix the compiler error in the program below, please can we add the following (e.g. to boost/bind.hpp) - </p> <pre class="wiki">#include &lt;boost/weak_ptr.hpp&gt; namespace boost { namespace _bi { template&lt;class T&gt; bool ref_compare( value&lt; weak_ptr&lt;T&gt; &gt; const &amp; a, value&lt; weak_ptr&lt;T&gt; &gt; const &amp; b, long ) { return !(a.get() &lt; b.get()) &amp;&amp; !(b.get() &lt; a.get()); } } } </pre><p> -- main.cpp -- </p> <pre class="wiki">#include &lt;boost/function_equal.hpp&gt; #include &lt;boost/bind.hpp&gt; #include &lt;boost/weak_ptr.hpp&gt; int h( boost::weak_ptr&lt;void&gt; wp ) { return wp.use_count(); } template &lt; typename F &gt; bool self_equal( F f_ ) { return function_equal( f_, f_ ); } int main( int argc, char * const argv[] ) { self_equal( boost::bind( h, _1 ) ); // OK self_equal( boost::bind( h, boost::weak_ptr&lt;void&gt;() ) ); // compiler error return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2849 Trac 1.4.3 Peter Dimov Thu, 26 Mar 2009 00:27:26 GMT status changed https://svn.boost.org/trac10/ticket/2849#comment:1 https://svn.boost.org/trac10/ticket/2849#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Peter Dimov Thu, 26 Mar 2009 00:43:18 GMT <link>https://svn.boost.org/trac10/ticket/2849#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2849#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51979" title="Add ref_compare for weak_ptr. Refs #2849.">[51979]</a>) Add ref_compare for weak_ptr. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2849" title="#2849: Bugs: function_equal should work with binds holding weak_ptr values (closed: fixed)">#2849</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sat, 28 Mar 2009 20:56:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2849#comment:3 https://svn.boost.org/trac10/ticket/2849#comment:3 <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/52041" title="Merge [51979] to release. Closes #2849.">[52041]</a>) Merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/51979" title="Add ref_compare for weak_ptr. Refs #2849.">[51979]</a> to release. Closes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2849" title="#2849: Bugs: function_equal should work with binds holding weak_ptr values (closed: fixed)">#2849</a>. </p> Ticket