|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-22 11:35:00
----- Original Message -----
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.
Okay, I get the picture, thanks.
I am still confused about the details of your pair above. When you say
typeinfo, are you referring to std::type_info, or is it just a placeholder?
> > precedes?
> > is_ordered?
>
> I had std::type_info::before in mind.
I hate to open this debate again, but that makes sense to me as a member
function, but much less so as a free function.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk