Skip to content

Conversation

hrissan
Copy link

@hrissan hrissan commented Jun 16, 2017

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))

hrissan added 3 commits June 16, 2017 18:48
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))
@hoytech
Copy link

hoytech commented Jul 23, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants