Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-03-06 18:30:14


Matthias Kaeppler <nospam_at_[hidden]> writes:

> Pavel Chikulaev wrote:
>> "Matthias Kaeppler" <nospam_at_[hidden]> wrote in message
>> news:d0futi$j8m$1_at_sea.gmane.org...
>>
>>>>But I can do it with Boost::Bind:
>>>> std::sort(vec.begin(), vec.end(), boost::bind(std::less<int>(),
>>>> *_1, *_2));
>>>
>>> This looks new to me. What exactly does this do? Sort the container
>>> of pointers by applying std::less to the pointees?
>>>
>>>
>>>>Boost::Bind's solution is much better that yours, because it constists
>>>>indirector_unary, indirector_binary, indirector_ternary and so on.
>> Read boost::bind documentation
>> http://www.boost.org/libs/bind/bind.html.
>> Pavel Chikulaev _______________________________________________
>> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>
> That doesn't work for me.
>
> std::sort(vec.begin(), vec.end(), boost::bind(std::less<int>(), *_1, *_2));
>
> deref.cpp:154: error: no match for 'operator*' in '*<unnamed>::_1'
> deref.cpp:154: error: no match for 'operator*' in '*<unnamed>::_2'
>
> Am I missing something?

No, he should have told you to use the _1 and _2 from the Boost
Lambda library. Bind won't handle the *s.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk