Boost logo

Boost Users :

From: Daniel James (daniel_at_[hidden])
Date: 2005-02-07 07:34:11


Daniel James wrote:
> Surya Kiran Gullapalli wrote:
>
>> The best way should be to use bind (or am i wrong here ?) from Boost
>> library.
>>
>> But i'm not getting the syntax correctly here.
>>
>> the crude way could be
>>
>> *stable_sort (files.begin(), files.end(), (bind (&File::get_size, _1)
>> > bind (&File::get_size, _2))) ;*
>>
>> that is call get_size() on first argument, and call get_size() on
>> second argument, and compare those values, and return a boolean value.
>>
>> Can anybody please help me out with the syntax here. ??
>
>
> Right syntax, wrong library. You can do this with Boost.Lamba.
[snip]

Or if you really want to use Boost.Bind, something like:

     using namespace boost;

     stable_sort(files.begin(), files.end(),
             (bind(std::greater<int>(),
                 bind(&File::get_size, _1),
                 bind(&File::get_size, _2)))) ;

Remembering to include <functional> to get std::greater.

Daniel


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