Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-06 08:25:19

From: "Gabriel Dos Reis" <gdr_at_[hidden]>
> "Peter Dimov" <pdimov_at_[hidden]> writes:
> [...]
> | Another, more practical, argument is that if you specialize std::less,
> | will work:
> |
> | std::set< interval > s;
> |
> | std::vector< interval > v;
> | std::sort(v.begin(), v.end(), less<interval>());
> |
> | but this (for example) will not:
> |
> | std::set< std::pair<interval, int> > s2;
> Yes, but the problem isn't with interval. Is it?

Yes, it is. std::pair is just an example. You can "fix" std::pair but you
can't fix every compound object in existence.

Once you decouple std::less from operator<, you now need to always define a
less<> specialization in terms of less<> whenever you would define an
operator< in terms of operator<.

This is not the original intent of the STL. The original intent is for
less<> to alias operator<, just like the other function objects alias the
other operators.

less<> was decoupled from operator< for pointers and it went downhill from
there. Fortunately pointers are totally ordered on most platforms that
matter, so this doesn't have much of an impact.

Boost list run by bdawes at, gregod at, cpdaniel at, john at