VS2012版本下std::function存在问题,链接:https://stackoverflow.com/questions/13096162/stdfunction-not-compiling-in-vs2012
#include <iostream>
#include <functional>
struct Foo {
Foo(int num) : num_(num) {}
void print_add(int i) const { std::cout << num_+i << '
'; }
int num_;
};
int main()
{
// store a call to a member function
std::function<void(const Foo&, int)> f_add_display = std::mem_fn(&Foo::print_add);
Foo foo(314159);
f_add_display(foo, 1);
}