#include <iostream>
#include <memory>
namespace rocksdb {
class DB {
public:
virtual ~DB() = default;
virtual void doIt() = 0;
static void Open(DB **db);
};
class DB_Impl : public DB {
public:
DB_Impl() { std::cout << "Created" << std::endl; }
~DB_Impl() { std::cout << "Destroyed" << std::endl; }
void doIt() override {}
};
void DB::Open(DB **db) {
*db = new DB_Impl;
}
}
int main() {
std::unique_ptr<rocksdb::DB> _db;
rocksdb::DB* db;
rocksdb::DB::Open(&db);
_db = std::unique_ptr<rocksdb::DB>(db);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgoKbmFtZXNwYWNlIHJvY2tzZGIgewoJY2xhc3MgREIgewoJcHVibGljOgoJCXZpcnR1YWwgfkRCKCkgPSBkZWZhdWx0OwoJCXZpcnR1YWwgdm9pZCBkb0l0KCkgPSAwOwoJCXN0YXRpYyB2b2lkIE9wZW4oREIgKipkYik7Cgl9OwoKCWNsYXNzIERCX0ltcGwgOiBwdWJsaWMgREIgewoJcHVibGljOgoJCURCX0ltcGwoKSB7IHN0ZDo6Y291dCA8PCAiQ3JlYXRlZCIgPDwgc3RkOjplbmRsOyB9CgkJfkRCX0ltcGwoKSB7IHN0ZDo6Y291dCA8PCAiRGVzdHJveWVkIiA8PCBzdGQ6OmVuZGw7IH0KCQl2b2lkIGRvSXQoKSBvdmVycmlkZSB7fQoJfTsKCgl2b2lkIERCOjpPcGVuKERCICoqZGIpIHsKCQkqZGIgPSBuZXcgREJfSW1wbDsKCX0KfQoKaW50IG1haW4oKSB7CgoJc3RkOjp1bmlxdWVfcHRyPHJvY2tzZGI6OkRCPiBfZGI7CgoJcm9ja3NkYjo6REIqIGRiOwoJcm9ja3NkYjo6REI6Ok9wZW4oJmRiKTsKCV9kYiA9IHN0ZDo6dW5pcXVlX3B0cjxyb2Nrc2RiOjpEQj4oZGIpOwoKCXJldHVybiAwOwp9