#include <iostream>
#include <memory>
class A{};
void dostuff1(A * a)
{
std::unique_ptr<A> ptr(a);
}
void dostuff2(std::unique_ptr<A> a)
{
std::unique_ptr<A> ptr = std::move(a);
}
int main()
{
dostuff1(new A());
dostuff2(std::make_unique<A>());
std::unique_ptr<A> a;
//dostuff2(a); //this will error out
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgoKY2xhc3MgQXt9OwoKdm9pZCBkb3N0dWZmMShBICogYSkKewoJc3RkOjp1bmlxdWVfcHRyPEE+IHB0cihhKTsKfQoKdm9pZCBkb3N0dWZmMihzdGQ6OnVuaXF1ZV9wdHI8QT4gYSkKewoJc3RkOjp1bmlxdWVfcHRyPEE+IHB0ciA9IHN0ZDo6bW92ZShhKTsJCn0KCmludCBtYWluKCkKewoJZG9zdHVmZjEobmV3IEEoKSk7Cglkb3N0dWZmMihzdGQ6Om1ha2VfdW5pcXVlPEE+KCkpOwoKCXN0ZDo6dW5pcXVlX3B0cjxBPiBhOwoJLy9kb3N0dWZmMihhKTsgLy90aGlzIHdpbGwgZXJyb3Igb3V0CgoJcmV0dXJuIDA7Cn0=