Boost C++ Libraries: Ticket #4796: Empty shared_ptr_nmt returns use_count() = 1 https://svn.boost.org/trac10/ticket/4796 <p> If you construct an empty shared_ptr, the use_count() method will return 0. This is indicated in the documentation as "Postconditions: use_count() == 0 &amp;&amp; get() == 0." </p> <p> If I look at the implementation in boost/smart_ptr/detail/shared_ptr_nmt.hpp, the default constructed shared_ptr will create a count_type(1). That means that use_count() will return 1 even if I construct it without any initial value. This is inconsistent IMHO. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4796 Trac 1.4.3 Peter Dimov Wed, 27 Oct 2010 15:43:24 GMT <link>https://svn.boost.org/trac10/ticket/4796#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4796#comment:1</guid> <description> <p> Yes, I suppose it is. shared_ptr_nmt.hpp (nmt - no member templates), however, is no longer used by any of the compilers with which Boost is tested. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 27 Nov 2010 15:42:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4796#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4796#comment:2</guid> <description> <p> If there is not a real test case we should close the ticket. </p> </description> <category>Ticket</category> </item> <item> <author>smork1@…</author> <pubDate>Mon, 29 Nov 2010 08:18:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4796#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4796#comment:3</guid> <description> <p> I propose this ticket should be closed indeed. The explanation that this is a no longer tested/used version of shared_ptr is sufficient for me. Your development time is probably best spent on the more recent version. Thanks for the acknowledgement though :) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Thu, 24 Feb 2011 17:21:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4796#comment:4 https://svn.boost.org/trac10/ticket/4796#comment:4 <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