Boost logo

Boost :

From: Joe Gottman (jgottman_at_[hidden])
Date: 2003-05-04 00:13:03


I have a question about the shared_ptr specification recently accepted into
the TR. I'm not sure whether it belongs here or in comp.std.c++.

   Under the boost implementation, two empty (i.e. default-constructed)
shared_ptr's are equivalent under the (!(x < y) && ! (y < x) ) equivalence
relation. But the text in the TR specifying operator< says that two
shared_ptr's are equivalent this way if and only if they share ownership.
Since an empty shared_ptr doesn't share ownership with anything, not even
itself, this seems to make shared_ptr::operator< not a strict weak ordering,
which would be a bug in the specification.

   I think the text in the TR should be modified to say that two
shared_pointer's are equivalent if and only if they share ownership or are
both empty. This way, if you had a set of shared_ptr<int>'s and you wanted
to know if it contained any empty shared_ptr's, you could simply type
  if (mySet.find(shared_ptr<int>()) != mySet.end()) // do whatever.

Joe Gottman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk