From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-05-24 17:52:37
Darin Adler wrote:
> Well, this is only my opinion (and apparently Andrei's too, given what he
> said in his book). I'll try to be clear here. I'm not trying to win a
> debate, but just present my thinking in as transparent a way as possible.
I'm also of the opinion that having std::less for a smart pointer
is (and should be provided), but not operator<.
> That's why I added the std::less overload (not
> specialization, I guess) for shared_ptr.
std::less is a class, so it can't be an overload, only a
> Whether shared_ptr's can also be
> compared in other contexts seemed less important to me,
It's undefined behavior to compare ordinary pointers with
operator<, unless they point to element of the same array.
Two shared_ptrs can never point into the same array, so
by analogy, there is never a reason to compare shared_ptr with
operator<, because the equivalent ordinary pointers cannot
be (legally) compared by operator< either. It's nice that
a shared_ptr class gives us the option to actually flag this
invalid usage as an error.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk