#include <iostream>
#include <string>
#include <memory>
struct A : std::enable_shared_from_this<A>
{
~A(){std::cout<<"abc"<<std::endl;}
};
int main()
{
A* a = new A;
std::shared_ptr<A> p1(a);
std::shared_ptr<A> p2(a);
// both p1 and p2 will delete the object a
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bWVtb3J5PgoKc3RydWN0IEEgOiBzdGQ6OmVuYWJsZV9zaGFyZWRfZnJvbV90aGlzPEE+CnsKICAgIH5BKCl7c3RkOjpjb3V0PDwiYWJjIjw8c3RkOjplbmRsO30KfTsKCmludCBtYWluKCkKewogICAgQSogYSA9IG5ldyBBOwogICAgc3RkOjpzaGFyZWRfcHRyPEE+IHAxKGEpOwogICAgc3RkOjpzaGFyZWRfcHRyPEE+IHAyKGEpOwoKICAgIC8vIGJvdGggcDEgYW5kIHAyIHdpbGwgZGVsZXRlIHRoZSBvYmplY3QgYQp9