Opened 6 years ago

Closed 5 years ago

#842 closed request (fixed)

functor to compare pairs wrt to first only (ignore second)

Reported by: Peter Owned by: Peter
Priority: minor Milestone: yat 0.14
Component: utility Version: trunk
Keywords: Cc:


I have a vector<pair<A, B>> and wanna sort them wrt first. B has no operator< so can't use std::pair's operator<.

Couldn't find this in std with a quick look.

Change History (4)

comment:1 Changed 6 years ago by Peter

Milestone: yat 0.x+yat 0.14
Version: trunk

comment:2 Changed 6 years ago by Peter

Owner: changed from Jari Häkkinen to Peter
Status: newassigned

comment:3 Changed 6 years ago by Peter

The class would be identical with

template<typename T1, typename T2>
compose_f_gx_hy<std::less<std::pair<T1, T2>,
                PairFirst<std::pair<T1, T2>,
                PairFirst<std::pair<T1, T2> >

so question is if we should leave it there or perhaps implement a convenient alias (inherited from compose_f_gx_hy)

comment:4 Changed 5 years ago by Peter

Resolution: fixed
Status: assignedclosed

(In [3466]) closes #842. Document how to combine compose_f_gx_hy, PairFirst?, and std::less to accomplish a functor that compares pairs ignore .second. Also include such an example in the test.

Note: See TracTickets for help on using tickets.