I'm using RocksDB which requires a pointer to a pointer to open:
rocksdb::DB* db{nullptr};
const rocksdb::Status status = rocksdb::DB::Open(options, path, &db);
As expected, I'd like to use a unique_ptr
. However, unfortunately if I do this:
std::unique_ptr<rocksdb::DB> db;
const rocksdb::Status status = rocksdb::DB::Open(options, fileFullPath, &(db.get()));
I get:
error: lvalue required as unary ‘&’ operand
and if I use a raw pointer and then create a unique_ptr
:
std::unique_ptr<rocksdb::DB> _db; // Class member
rocksdb::DB* db;
const rocksdb::Status status = rocksdb::DB::Open(options, fileFullPath, &db));
_db = std::make_unique<rocksdb::DB>(db);
I get:
error: invalid new-expression of abstract class type ‘rocksdb::DB’
{ return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
How can I use unique_ptr
with this?