Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-09-05 19:29:46


From: "Sylvain Pion" <pion_at_[hidden]>

> 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.

Right.

> And unless I'm mistaken, std::complex doesn't provide such an object.

Right.

> There is currently in the code a commented specialization of std::less
for
> interval. We need to decide what do with this thing.

There are arguments which say it's undefined behavior to specialize
std::less so that it does anything other than x < y.

> 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.

IMO it depends how important a use case intervals-as-associative-keys is. I
have no opinion on that, but if I had to guess I'd say it's not important.

> > > > 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.

Fair enough.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com


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