Boost logo

Boost Users :

Subject: Re: [Boost-users] Bind and overloaded operators in Visual Studio 2008
From: Sergey Sadovnikov (flex_ferrum_at_[hidden])
Date: 2008-11-13 05:28:17


Hello, Benjamin.

Thursday, November 13, 2008 at 1:19:30 PM you wrote:

>> The bug you're seeing is in Dinkumware's bind, not boost's.
>> Try using boost::bind explicitly and I suspect it will work fine.

BS> Thanks for the quick answer. I replaced it with

BS> #include <boost/bind.hpp>
BS> std::find_if(v.begin(), v.end(), boost::bind( &Foo::first_, _1 ) == test
BS> );

I think what the better way is to use boost::lambda::bind
instead of boost::bind for such purposes. If you'll use boost::lambda
you will have guarantee what you code remains unambiguous. Try:

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>

namespace bl = boost::lambda;

std::find_if(v.begin(), v.end(), bl::bind( &Foo::first_, bl::_1 ) ==
test);

-- 
Best Regards,
 Sergey                          mailto:flex_ferrum_at_[hidden]

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