leveldb icon indicating copy to clipboard operation
leveldb copied to clipboard

Question: how to cast to int

Open fadhil-riyanto opened this issue 6 months ago • 3 comments

Hi, I have following map

std::map<std::string, int> db;

which in future, I want load data from leveldb to the memory by looping all of keys and insert to the std::map, I was do this

leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());

for (it->SeekToFirst(); it->Valid(); it->Next()) {
        db.insert(
                {
                        it->key().ToString(),
                        it->value()
                }
        );
}
assert(it->status().ok());

which get the key as string, then get the value. my question how do I can cast back the "value" to int?

fadhil-riyanto avatar Aug 21 '24 16:08 fadhil-riyanto