This code fails to compile under VS2010:
#include <functional>
using namespace std;
void test()
{
auto f = [] (int) {};
bind(f, 10);
}
It gives a long error pointing to the internals of bind implementation.
If I switch to a normal function instead of a lambda, the bind works fine, so I believe this is a bug in VS2010 but maybe I'm missing something.
Can you help me?
It seems VC10 cannot cope with lambdas as arguments to std::bind. It seems to expect either a function pointer or a function object. I don't know whether this is a bug, but I suspect it is, since lambda function should become function objects during compilation.
Anyway, if you are in need of a workaround, this compiles for me:
std::function<void(int)> func = [] (int) {};
std::bind(func, 10);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With