fork(1) download
  1. #include <functional>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct A
  6. {
  7. int x;
  8. };
  9.  
  10. function<int()> GetFunc()
  11. {
  12. auto c = make_shared<A>(A{0});
  13. return [=]{ return c->x++; };
  14. }
  15.  
  16. int main()
  17. {
  18. auto x = GetFunc();
  19. return x()+x()+x()-3;
  20. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
Standard output is empty