26 Mar
2004
26 Mar
'04
6:42 p.m.
Duane Murphy wrote:
--- At Fri, 26 Mar 2004 00:48:49 +0100, Daniel Wallin wrote:
struct X { int a; };
std::vector<X> v;
With boost.bind:
std::sort( v.begin() , v.end() , boost::bind( std::less<int>() , boost::bind(&X::a, _1) , boost::bind(&X::a, _2) ) );
I don't know lambda, so I won't comment on that. But, I thought that the first parameter to bind was a function pointer? You can bind to an address?
Please explain how this works?
&X::a is not an address. It is a member pointer. boost::bind allows you to work with pointers to members as if they were function objects. It does this by automatically translating &X::a to boost::mem_fn(&X::a).