lmdbxx
lmdbxx copied to clipboard
This put overload fixes a very major bug.
Consider dbi.put(txn, key, val{data, size}); as val is not an lvalue, the following template overload will be selected. template<typename K, typename V> bool put(MDB_txn* const txn, const K& key, const V& val, const unsigned int flags = default_put_flags) { const lmdb::val k{&key, sizeof(K)}; lmdb::val v{&val, sizeof(V)}; return lmdb::dbi_put(txn, handle(), k, v, flags); } Which instead of storing (data, size) will store (&val, sizeof(val))
I agree that these templated methods were a bad idea. I have removed them in my lmdbxx fork, and documented some alternatives in the README.