fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <functional>
  4.  
  5. using namespace std;
  6.  
  7. class Test
  8. {
  9. public:
  10. void f() { cout << "Test::f\n"; }
  11. };
  12.  
  13. void g() { cout << "g\n"; }
  14.  
  15.  
  16. int main(int argc, const char * argv[])
  17. {
  18. Test t;
  19. std::function<void(void)> f[] =
  20. {g,std::bind(&Test::f,t), [](){cout << "lambda\n";}};
  21. for(auto s: f) s();
  22. }
  23.  
  24.  
Success #stdin #stdout 0s 4468KB
stdin
Standard input is empty
stdout
g
Test::f
lambda