fork(3) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class foo {
  6. public:
  7. foo():a(new int()) { std::cout << "ctor" << std::endl; }
  8. foo(const foo & x) { std::cout << "copy" << std::endl; }
  9. foo(foo && x) { std::cout << "move" << std::endl; }
  10. std::shared_ptr<int> a;
  11. };
  12.  
  13. int main() {
  14. foo a;
  15. foo b;
  16. auto f = [a, b] () {cout<<!a.a<<endl; };
  17. f();
  18. auto f2(std::move(f));
  19. f();
  20. return 0;
  21. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
ctor
ctor
copy
copy
1
move
move
1