Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-22 11:22:37


From: "David Abrahams" <david.abrahams_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
> >
> > What convinced me that operator< is the right ordering primitive (in the
> > context of the current standard library design) was that I needed to
make
> a
> >
> > std::map<std::pair<typeinfo, typeinfo>, ...>
> >
> > and a specialized std::less doesn't work here, while an operator< does.
>
> Sorry, I must be dense. Are you saying that you define your operator< in
the
> global namespace? Why wouldn't the standard's version of operator< for
pair
> work without intervention?

Because std::pair<T, U>::operator< uses T::operator< and U::operator<, not
less<T> and less<U>; you can't use, say, std::pair<shared_ptr, int> as a key
with only std::less<shared_ptr> defined.

> > In any event, if we really have to reinvent the ordering primitive, I
> > suggest we _not_ name it boost::less (boost::before maybe.)
>
> precedes?
> is_ordered?

I had std::type_info::before in mind.

> > And of course, as a MSVC user, I prefer something that works over
> something
> > that doesn't work.
>
> Unlike the rest of us? ;-)

My point was that operator< works on MSVC, while less<> cannot be partially
specialized. :-)

--
Peter Dimov
Multi Media Ltd.

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