Boost logo

Boost :

From: Kevin Spinar (spinarkm_at_[hidden])
Date: 2006-07-11 11:59:24


On 7/11/06, Philippe Vaucher <philippe.vaucher_at_[hidden]> wrote:
>
> We could maybe also do some template / macro fun to help them to define
> those ? Something like :
>
> #define DEF_OP_MIN(cont) bool cont::operator<(const cont& a, const cont&b) {
> return &a < &b; }

That's not a valid way to define a operator< that can be used to store
objects in an associative container. It is (implicitly?) expected
that if an object is copied constructed from another object, the
original object and the copied object will have the same total
ordering. I justify this statement by the fact that containers are
required to have linear complexity for copy construction, which
implies the elements have to be copy constructed and maintain the same
order as the original elements.

Kevin Spinar


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