fork download
  1. #include <iostream>
  2. #include <utility>
  3. using namespace std;
  4.  
  5. template <typename F>
  6. void bar(const F& f)
  7. {
  8. auto d = f.x;
  9. f();
  10. }
  11.  
  12. void do_something (int x) { }
  13.  
  14. int main()
  15. {
  16. struct Tmp {
  17. int &x;
  18. Tmp (int& x) : x(x) {}
  19. void operator() () const {
  20. do_something(x);
  21. }
  22. };
  23. int x;
  24. Tmp t(x);
  25. bar(t);
  26. }
  27.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty