fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class Foo
  6. {
  7. Foo() {}
  8. public:
  9. static std::shared_ptr<Foo> Make()
  10. {
  11. struct Bootstrap : public Foo
  12. {
  13. ~Bootstrap()
  14. {
  15. std::cout << "Bootstrap dtor";
  16. }
  17. };
  18. return std::make_shared<Bootstrap>();
  19. }
  20.  
  21. void Print()
  22. {
  23. std::cout << "Hello, world!" << std::endl;
  24. }
  25. };
  26.  
  27. int main()
  28. {
  29. auto foo = Foo::Make();
  30. foo->Print();
  31. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Hello, world!
Bootstrap dtor