Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-08-10 10:47:46


Olaf van der Spek wrote:
> On 8/9/07, Peter Dimov <pdimov_at_[hidden]> wrote:
>> Olaf van der Spek wrote:
>>
>>>>> sort(countries1.begin(), countries1.end(),
>>>>> _1->second > _2->second);
>>
>> sort( countries1.begin(), countries1.end(),
>>
>> bind( &countries_t::value_type::second, *_1 ) > bind(
>> &countries_t::value_type::second, *_2 )
>
> Thanks, that did the trick. I didn't know you could use bind like this
> too. But why does the simpler syntax not work?

Due to the way operator-> overloading works, it's hard to make _1->second do
what you want (and impossible for arbitrary identifiers and not just
'second'.)

The closest you can get with Lambda is _1 ->*
&countries_t::value_type::second.


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