Topic: Defect Report: shared_ptr::operator<() is not a strict weak ordering


Author: Joe Gottman <jgottman@carolina.rr.com>
Date: Fri, 21 Nov 2003 15:55:05 +0000 (UTC)
Raw View
[Note: Forwarded to C++ Committee. -sdc ]

    According to the draft Technical Report on Standard Library Extensions,
two shared_ptr's are equivalent under the !(a < b) && !(b < a) relationship
if and only if they share ownership.  But an empty (default constructed)
shared_ptr does not share ownership with anything, not even itself.  This
means that if a is an empty shared_ptr, it will not be equivalent to itself,
so operator< is not a strict weak ordering.  The same holds true for
weak_ptr's.

Suggested Resolution:

    Change the specification of shared_ptr::operator<() to say two
shared_ptr's are equivalent if and only if they share ownership or are both
empty.

   Change the specification of weak_ptr::operator<() to say two weak_ptr's
are equivalent if and only if they share ownership or are both empty.


Joe Gottman



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]