Alex Rivera | Logout

How to use lambda functions with boost::bind/std::bind in VC++ 2010?

Asked 2011-01-05T09:36:32.143
19

I have some lambda functions which I want to bind using either boost::bind or std::bind. (Don't care which one, as long as it works.) Unfortunately both of them give me different compiler erros:

auto f = [](){ cout<<"f()"<<endl; };
auto f2 = [](int x){ cout<<"f2() x="<<x<<endl; };

std::bind(f)(); //ok
std::bind(f2, 13)(); //error C2903: 'result' : symbol is neither a class template nor a function template

boost::bind(f)(); //error C2039: 'result_type' : is not a member of '`anonymous-namespace'::<lambda0>'
boost::bind(f2, 13)(); //error C2039: 'result_type' : is not a member of '`anonymous-namespace'::<lambda1>'

So, what is the simplest workaround for this?

Edit
Report

1 Answer

1

I think you might be interested in this MSDN forum post. Sounds like the poster had the same problem as yours, and lodged a bug with MS Connect.

answered 2011-01-05T10:05:59.267

Your Answer