Opened 12 years ago

Closed 12 years ago

#4796 closed Bugs (wontfix)

Empty shared_ptr_nmt returns use_count() = 1

Reported by: B van den Hout <smork1@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

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.

Change History (4)

comment:1 by Peter Dimov, 12 years ago

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.

comment:2 by viboes, 12 years ago

If there is not a real test case we should close the ticket.

comment:3 by smork1@…, 12 years ago

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 :)

comment:4 by Peter Dimov, 12 years ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.