Subject: [Boost-bugs] [Boost C++ Libraries] #4796: Empty shared_ptr_nmt returns use_count() = 1
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-27 10:45:31
#4796: Empty shared_ptr_nmt returns use_count() = 1
-----------------------------------------------+----------------------------
Reporter: B van den Hout <smork1@â¦> | Owner: pdimov
Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
Version: Boost 1.44.0 | Severity: Problem
Keywords: |
-----------------------------------------------+----------------------------
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 && get() == 0."
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.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4796> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC