Boost logo

Boost :

From: Kevin Spinar (spinarkm_at_[hidden])
Date: 2006-07-15 14:25:58


On 7/13/06, Christopher Eltschka <celtschk_at_[hidden]> wrote:
>
> operator< and operator== of course can be defined anywhere the
> std::rel_ops operators will find them (e.g. they could be defined as
> class members instead).

Note that you really only have to define operator< as operator== could
be written as

template<class T, class U>
bool operator==(const T &lhs, const U &rhs) {
   return !(lhs < rhs) && !(rhs < lhs);
}

and the user could still define operator== themselves for optimization
purposes (then you should make sure to define operator!= in terms of
operator==).

Are you going to allow comparision of different types (like I showed
above) or strictly comparision among objects of the same type?

> Alternatively it could be extended to support other typical operator implementations
> not covered by the standard, e.g. defining operator@ in terms of operator@=.

Sounds good.

Kevin Spinar


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