Boost logo

Boost Users :

From: Chris Jurney (cjurney_at_[hidden])
Date: 2004-03-29 14:19:49


In this case, I could have used pair's operator<, but if I have a class
by value as the second item of the pair that doesn't have a meaningful
operator<, I want to ignore it in the sort. Thanks for all the help,
guys.

Chris

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Victor A.
Wagner Jr.
Sent: Friday, March 26, 2004 8:40 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Defining less on member variables/functions

why do you want to sort ONLY on the 1st element of the pair?

At Thursday 2004-03-25 11:34, you wrote:
>content-class: urn:content-classes:message
>Content-Type: multipart/alternative;
> boundary="----_=_NextPart_001_01C41297.D800D40A"
>
>I've had this same pattern come up 4 or 5 times now, and each time I've

>been unable to find a stl + boost solution that allowed me to do what I

>want without writing my own less function. Basically, I want something

>that will let me do a sort, or define a map on structs or pairs without

>writing a less that compares the member variable or ..first. My last
attempt:
>
>vector<pair<float, float>> myVector
>std::sort(myVector.begin(), myVector.end(), _1.first < _2.first);
>
>No such luck. It looks like I can do operator * and & on lambda
objects,
>but not access members through them. Is there anything in boost, stl,
or
>elsewhere that lets me not write this:
>
>class myLess
>{
> bool operator() (pair<float, float> a, pair<float, float>b)
> {return a.first < b.first;}
>}
>
>Thanks for any help,
>Chris
>
>
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users

Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law"

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net