fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. template<typename T>
  6. struct MyShared : public std::shared_ptr<T>
  7. { };
  8.  
  9. struct X {
  10. int n_;
  11. X(int n) : n_(n) { }
  12. ~X() { cout << "~X " << n_ << "\n"; }
  13. };
  14.  
  15. int main() {
  16. MyShared<X> p;
  17. p.reset(new X(3));
  18. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
~X 3