weak_ptr
comparisons incompletely resolvedSection: 20.3.2.3.6 [util.smartptr.weak.obs] Status: C++11 Submitter: Daniel Krügler Opened: 2009-10-10 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [util.smartptr.weak.obs].
View all issues with C++11 status.
Discussion:
The
n2637
paper suggested several updates of the ordering semantics of shared_ptr
and weak_ptr
, among those the explicit comparison operators of weak_ptr
were
removed/deleted, instead a corresponding functor owner_less
was added.
The problem is that
n2637
did not clearly enough specify, how the previous wording parts describing
the comparison semantics of weak_ptr
should be removed.
[ 2009-11-06 Howard adds: ]
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
Proposed resolution:
Change 20.3.2.3 [util.smartptr.weak]/2 as described, the intention is to fix
the now no longer valid requirement that weak_ptr
is LessComparable
[Note the deleted comma]:
Specializations of
weak_ptr
shall beCopyConstructible
,andCopyAssignable
,andallowing their use in standard containers.LessThanComparable
,
In 20.3.2.3.6 [util.smartptr.weak.obs] remove the paragraphs 9-11 including prototype:
template<class T, class U> bool operator<(const weak_ptr<T>& a, const weak_ptr<U>& b);Returns: an unspecified value such that
operator<
is a strict weak ordering as described in 25.4;under the equivalence relation defined byoperator<
,!(a < b) && !(b < a)
, twoweak_ptr
instances are equivalent if and only if they share ownership or are both empty.
Throws: nothing.
[Note: Allowsweak_ptr
objects to be used as keys in associative containers. — end note]