|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-06 07:28:17
From: "David Abrahams" <dave_at_[hidden]>
> From: "Sylvain Pion" <pion_at_[hidden]>
>
> > There is currently in the code a commented specialization of std::less
> for
> > interval. We need to decide what do with this thing.
Please don't specialize std::less. :-)
> There are arguments which say it's undefined behavior to specialize
> std::less so that it does anything other than x < y.
Another, more practical, argument is that if you specialize std::less, this
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;
std::vector< interval > v;
std::sort(v.begin(), v.end());
std::less<> is just a function object "alias" of operator<.
So if you want sets of intervals to work (without an explicit comparator),
provide an operator< that is a strict weak ordering.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk