|
Boost : |
From: David Bergman (davidb_at_[hidden])
Date: 2002-09-05 19:11:01
Sylvain,
I almost agree. But, as Herve pointed out earlier when reminding us that
an interval actually is more than its endpoints, one should not diverge
into the road of std::pair or std::complex too far. An interval is
actually quite different, except in its possible representation and
syntax.
The lexicographic order, which is total and fairly "natural" in
intervals, is a bit awkward in std::complex (unless we regard the
Re-part as more important than the Im-part, which does happen,
admittedly...)
So, we might have a possibility here to actually (a) use intervals in
STL structures and algorithms and (b) have equivalence being sound. Than
further relations can be defined, or supplied by the developer.
/David
-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Sylvain Pion
Sent: Thursday, September 05, 2002 7:58 PM
To: boost_at_[hidden]
Subject: Re: [boost] Interval Library and comparison operators
On Thu, Sep 05, 2002 at 06:49:15PM -0400, David Abrahams wrote:
> I'm not suggesting that it is. I'm only saying that you need something
> of the kind for most applications if you want to use them as map keys.
> For that reason, I'd suggest providing an appropriate compare object
> type which can be passed as an argument to std::map<>.
Note that from this point of view, boost::interval is essentially the
same thing as std::complex. And unless I'm mistaken, std::complex
doesn't provide such an object.
There is currently in the code a commented specialization of std::less
for interval. We need to decide what do with this thing.
I would be on the opinion to not define such an object.
Let's say that it's for the same reasons why there's none for
std::complex either.
> > > 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 :)
>
> No, they're usually considered (by me) to be useless, since they don't
> apply inside generic algorithms. Before they were nested inside
> std::rel_ops they were evil.
I see them equally useless for interval.
-- Sylvain _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk