#include <memory>
#include <iostream>
class A
{
public:
A() { std::cout << "Hi" << std::endl; }
~A() { std::cout << "Bye" << std::endl; }
};
class B
{
public:
B(): a(new A()) {};
//~B() {} <-- destructor is no longer needed, the unique_prt will delete the object for us
private:
std::unique_ptr<A> a;
};
int main(int argc, char* argv[])
{
B b;
}
I2luY2x1ZGUgPG1lbW9yeT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQQp7CnB1YmxpYzoKICAgIEEoKSB7IHN0ZDo6Y291dCA8PCAiSGkiIDw8IHN0ZDo6ZW5kbDsgfQogICAgfkEoKSB7IHN0ZDo6Y291dCA8PCAiQnllIiA8PCBzdGQ6OmVuZGw7IH0KfTsKCmNsYXNzIEIKewpwdWJsaWM6CiAgICBCKCk6IGEobmV3IEEoKSkge307CiAgICAvL35CKCkge30gPC0tIGRlc3RydWN0b3IgaXMgbm8gbG9uZ2VyIG5lZWRlZCwgdGhlIHVuaXF1ZV9wcnQgd2lsbCBkZWxldGUgdGhlIG9iamVjdCBmb3IgdXMKcHJpdmF0ZToKICAgIHN0ZDo6dW5pcXVlX3B0cjxBPiBhOwp9OwoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIqIGFyZ3ZbXSkKewogICAgQiBiOwp9