fork download
  1. #include <iostream>
  2.  
  3. struct X{
  4. X(){}
  5. X(X const&){ std::cout << "X copy\n"; }
  6. };
  7.  
  8. struct Y{
  9. void f(){
  10. auto x_ = x;
  11. [x_]{}();
  12. }
  13.  
  14. void g(){
  15. auto& x_ = x;
  16. [x_]{}();
  17. }
  18.  
  19. X x;
  20. };
  21.  
  22. int main(){
  23. Y y;
  24. y.f();
  25. std::cout << "====\n";
  26. y.g();
  27. }
  28.  
  29.  
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
X copy
X copy
====
X copy