Boost logo

Boost :

From: Scott McCaskill (scott_at_[hidden])
Date: 2001-08-16 19:07:59


I'd like to propose a minor addition to smart_ptr.hpp: operator<() for
comparing two shared_ptrs. Without such an operator, it's not possible to
use shared_ptr in certain STL containers (such as set) without defining
one's own predicate.

Although certainly not a show-stopper, it does seem odd that one is required
to do this when operator==() and operator!=() do exist. Therefore, I think
it seems reasonable, consistent and useful to add operator<(). Comments?

// identical to existing operator==() except that '==' is replaced by '<'
template<typename T, typename U>
  inline bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b)
    { return a.get() < b.get(); }


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