diff --git a/include/beman/inplace_vector/inplace_vector.hpp b/include/beman/inplace_vector/inplace_vector.hpp index 6341d0b..b0fbd81 100644 --- a/include/beman/inplace_vector/inplace_vector.hpp +++ b/include/beman/inplace_vector/inplace_vector.hpp @@ -138,13 +138,19 @@ template struct trivial { constexpr ~trivial() = default; }; +// This is the base storage for non-trivial types. +// In this storage solution, elements are stored in type-erased byte storage, +// thus, reinterpret_cast must be used, +// which makes inplace_vector of non-trivial types non-constexpr-friendly. +// +// Note: This is not used if trivial union is supported. template struct raw_byte_based_storage { alignas(T) std::byte _d[sizeof(T) * N]; - constexpr T *storage_data(size_t i) noexcept { + T *storage_data(size_t i) noexcept { IV_EXPECT(i < N); return reinterpret_cast(_d) + i; } - constexpr const T *storage_data(size_t i) const noexcept { + const T *storage_data(size_t i) const noexcept { IV_EXPECT(i < N); return reinterpret_cast(_d) + i; }