私は、boost :: bindまたはstd :: bindを使ってバインドしたいラムダ関数をいくつか持っています。 (限り、それが動作するようその1、気にしないでください。)残念ながら、両方のそれらの私に異なるコンパイラerrosを与える:lambda関数をboost :: bind/std :: bindでVC++ 2010で使う方法は?
だから、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>'
、このための最も簡単な回避策は何ですか?
なぜバインドを使用しますか? f()またはf2(1)を呼び出すことはできませんか? – Jagannath
@ジャガナート:これはもちろん単なる例ですが、実際にはバインド結果を関数オブジェクトに格納したいと考えています。 – Timo
なぜあなたはbindを使いたいですか?私はC++ 0xがクロージャを提供したと思いましたか? –