|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-03-26 13:42:51
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).
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