fork download
  1. #include <iostream>
  2. #include <functional>
  3. #include <map>
  4. #include <string>
  5.  
  6. void foo2(int a, int b)
  7. {
  8. std::cout << a+b << '\n';
  9. }
  10. std::string foo(int x)
  11. {
  12. if(x == 1)
  13. return "foo2";
  14. }
  15. int main()
  16. {
  17. std::map<std::string, std::function<void(int, int)>> m;
  18.  
  19. m["foo2"] = foo2;
  20.  
  21. int x = 1;
  22. int y = 2;
  23. int z = 3;
  24. m[foo(x)](y, z);
  25. }
  26.  
Success #stdin #stdout 0s 3068KB
stdin
Standard input is empty
stdout
5