|
Boost : |
From: Sylvain Pion (pion_at_[hidden])
Date: 2002-09-05 17:37:24
On Thu, Sep 05, 2002 at 06:13:04PM -0400, David Abrahams wrote:
> Sure, it meets the requirements, but it doesn't give you useful behavior.
Useful remark :)
> If you try to put (2,4) in a map which contains (3,3), nothing will happen.
> I agree with others that from an STL viewpoint, lexicographic ordering or
> something like it is the only one that makes sense.
Lexicographic ordering is fine for std::pair, because there is no assumption
on the kind of types you plug in (and since they are 2 different types, you
cannot compare them with each other, which doesn't let much room for anything
else than lexicographic order).
But I think it doesn't have much meaning on the intervals from the arithmetic
point of view, so I don't think it's a fine default for arithmetic intervals.
> It's not unreasonable to think of using a rel_ops approach for these
> things, though the operators won't propagate into generic algorithms:
>
> namespace mine {
> boost::interval f(boost::interval* start, boost::interval* finish)
> {
> using boost::intervals::my_preferred_comparison_ops;
>
> ... start[0] < start[1] ... ; // ok
>
> std::sort(start, finish); // error
> };
> }
Yes, and I thought the rel_ops were usually considered evil, because they are
too general, right ?
So they are there when you don't want them, but they are not there when you
want them :)
-- Sylvain
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk