fork download
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4.  
  5. void run(std::function<std::string(const int&)> func)
  6. {
  7. std::cout << "in run" << std::endl;
  8. }
  9.  
  10. int main()
  11. {
  12. auto get_functor = [&](const bool check)
  13. {
  14. return [&](const int& sr)->std::string
  15. {
  16. if(check)
  17. {
  18. return "some string";
  19. }
  20. return "another string";
  21. };
  22. };
  23. run(get_functor(true));
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
in run