fork(2) download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct MyDeleter
  6. {
  7. void operator() (void *) const
  8. {
  9. cout << "Deleter called\n";
  10. }
  11. };
  12.  
  13. int main() {
  14. typedef shared_ptr<void> S;
  15. cout << "1\n";
  16. {
  17. S x(nullptr, MyDeleter());
  18. cout << "2\n";
  19. {
  20. S y(x);
  21. cout << "3\n";
  22. }
  23. cout << "4\n";
  24. }
  25. cout << "5\n";
  26. return 0;
  27. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
1
2
3
4
Deleter called
5