diff --git a/src/lmdb/key_stream.h b/src/lmdb/key_stream.h index 0ad4c553c..dc7dc0d6f 100644 --- a/src/lmdb/key_stream.h +++ b/src/lmdb/key_stream.h @@ -133,6 +133,7 @@ namespace lmdb //! \pre `!is_end()` \return Current key K get_key() const noexcept { + static_assert(std::is_trivially_copyable(), "key is not memcpy safe"); assert(!is_end()); K out; std::memcpy(std::addressof(out), key.data(), sizeof(out)); diff --git a/src/lmdb/table.h b/src/lmdb/table.h index 4ded4ba54..48b94bc66 100644 --- a/src/lmdb/table.h +++ b/src/lmdb/table.h @@ -55,7 +55,7 @@ namespace lmdb static expect get_value(MDB_val value) noexcept { static_assert(std::is_same(), "bad MONERO_FIELD?"); - static_assert(std::is_pod(), "F must be POD"); + static_assert(std::is_trivially_copyable(), "F must be memcpy safe"); static_assert(sizeof(F) + offset <= sizeof(U), "bad field type and/or offset"); if (value.mv_size != sizeof(U)) diff --git a/src/lmdb/util.h b/src/lmdb/util.h index 493fc0bd8..89e4948a7 100644 --- a/src/lmdb/util.h +++ b/src/lmdb/util.h @@ -111,6 +111,7 @@ namespace lmdb template inline int less(MDB_val const* left, MDB_val const* right) noexcept { + static_assert(std::is_trivially_copyable(), "memcpy will not work"); if (!left || !right || left->mv_size < sizeof(T) + offset || right->mv_size < sizeof(T) + offset) { assert("invalid use of custom comparison" == 0); diff --git a/src/lmdb/value_stream.h b/src/lmdb/value_stream.h index d5a00ba02..a09c10e9a 100644 --- a/src/lmdb/value_stream.h +++ b/src/lmdb/value_stream.h @@ -162,8 +162,8 @@ namespace lmdb G get_value() const noexcept { static_assert(std::is_same(), "bad MONERO_FIELD usage?"); - static_assert(std::is_pod(), "value type must be pod"); - static_assert(std::is_pod(), "field type must be pod"); + static_assert(std::is_trivially_copyable(), "value type must be memcpy safe"); + static_assert(std::is_trivially_copyable(), "field type must be memcpy safe"); static_assert(sizeof(G) + uoffset <= sizeof(U), "bad field and/or offset"); assert(sizeof(G) + uoffset <= values.size()); assert(!is_end());