2 ms·
std::function works like the second syntax. struct Foo { void Bar(int) {} }; std::function <void(Foo&, int)> f = &Foo::Bar; int i; Foo foo;
by roel_v 11y ago
std::function works like the second syntax.
struct Foo { void Bar(int) {} };
std::function <void(Foo&, int)> f = &Foo::Bar;
int i;
Foo foo;
f(foo, i);
Which is confusing - you'd expect it to work like maybe 'foo.f(i)' or maybe 'foo.*f(i)' or something like that. Well the whole discussion (from what I understand) is what that 'something' should be (well I don't mean to imply that this is about how std::function should work; rather that this is one explicit manifestation of an issue that shows in several places).