fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct Gadget
  7. {
  8. void operator()(){}
  9. ~Gadget(){ cout << "~" << endl; }
  10. };
  11.  
  12. struct Widget
  13. {
  14. Gadget x;
  15. function<void()> operator()()
  16. {
  17. return [=]{ x(); cout << "lambda" << endl; };
  18. }
  19. };
  20. int main()
  21. {
  22. auto &&x = Widget{}();
  23. x();
  24. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
~
lambda