Boost C++ Libraries: Ticket #4544: shared_ptr seems to be mistake in unordered_set https://svn.boost.org/trac10/ticket/4544 <p> class Abc { }; </p> <p> int main() { </p> <blockquote> <p> boost::shared_ptr a(new Abc); boost::shared_ptr b(new Abc); unordered_set&lt;shared_ptr&lt;Abc&gt; &gt; xx; xx.insert(a); xx.insert(b); </p> </blockquote> <blockquote> <p> <em> always get 1 here, cout &lt;&lt; xx.hash_function()(a) &lt;&lt; " " &lt;&lt; xx.hash_function() &lt;&lt; endl; </em></p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> <p> judging two objects pointed by shared_ptr should compare the address of them, but how hash_function() always returns 1? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4544 Trac 1.4.3 Daniel James Tue, 17 Aug 2010 10:05:16 GMT status, component, milestone changed; owner set https://svn.boost.org/trac10/ticket/4544#comment:1 https://svn.boost.org/trac10/ticket/4544#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Daniel James</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">hash</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost.Jam 4.0.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> <p> Boost.Hash doesn't have support for <code>shared_ptr</code>, but there's a bug which causes it to convert them to bools (which is why it's always 1). If you define <code>BOOST_HASH_NO_IMPLICIT_CASTS</code> then it will correctly fail to compile. This will probably happen by default in Boost 1.45. </p> Ticket Daniel James Sun, 27 Feb 2011 08:40:31 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/4544#comment:2 https://svn.boost.org/trac10/ticket/4544#comment:2 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.47.0</span> </li> </ul> <p> shared_ptr now has support for hash in trunk <a class="changeset" href="https://svn.boost.org/trac10/changeset/69260" title="Add hash_value for shared_ptr; prevents hash_value( bool ) from being ...">[69260]</a>. </p> Ticket