Boost logo

Boost Users :

From: Jasper, Alexander (alexander.jasper_at_[hidden])
Date: 2005-07-28 01:52:54


Hi Oleg!

your function Handler::Test2 takes 2 arguments + this. But your code passes 3 arguments + this to the function boost::bind(&Handler::Test2, _1, _2, a, b)). If I'm not completely mistaken that cannot work. What did you expect the _2 to be in this case?. Using the _2 also implies that the resulting function of the bind expects 2 arguments. That is you cannot simply use it with for_each in that kind of way. This supplies only one parameter.

kind regards

Alex

> -----Ursprüngliche Nachricht-----
> Von: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]]Im Auftrag von
> Oleg Smolsky
> Gesendet: Donnerstag, 28. Juli 2005 03:22
> An: boost-users_at_[hidden]
> Betreff: [Boost-users] bosst::bind problem
>
>
> Hi all,
>
> I've just started using boost::bind and found the following problem:
>
> class Handler
> {
> public:
> bool Test1(std::string sComponent);
> bool Test2(std::string sComponent, std::string sAddress);
> };
>
> void Test()
> {
> std::vector<Handler> v;
>
> // This compiles
> std::string a, b;
> std::for_each(v.begin(), v.end(),
> boost::bind(&Handler::Test1, _1, a));
>
> // This doesn't compile
> //std::for_each(v.begin(), v.end(),
> // boost::bind(&Handler::Test2, _1, _2, a, b));
> }
>
> Environment: boost 1.32, VC8, WinXP.
>
> Any ideas?
>
> Thanks,
> Oleg.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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