For some reason, Visual Studio will not allow you to accept the address foo
, although it is a public member of Child
declared using the plain old C ++ 03 syntax.
std::function<void()> f = std::bind(&Child::foo, &c);
Directly calling the function still works fine:
c.foo();
Curiously, this means that you are using partial C ++ 11 VS2010 support to get around the flaw in your C ++ 03 support, using lambda to achieve the same effect as the bind
expression:
std::function<void()> f = [&c]{ c.foo(); };
source share