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