Skip to content

Commit bc95f51

Browse files
authored
Merge pull request #102 from bemanproject/river/non-constexpr
Better annotate functions relating to `raw_byte_based_storage`
2 parents ec09767 + eec23f0 commit bc95f51

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/beman/inplace_vector/inplace_vector.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,19 @@ template <class T, size_t N> struct trivial {
138138
constexpr ~trivial() = default;
139139
};
140140

141+
// This is the base storage for non-trivial types.
142+
// In this storage solution, elements are stored in type-erased byte storage,
143+
// thus, reinterpret_cast must be used,
144+
// which makes inplace_vector of non-trivial types non-constexpr-friendly.
145+
//
146+
// Note: This is not used if trivial union is supported.
141147
template <class T, size_t N> struct raw_byte_based_storage {
142148
alignas(T) std::byte _d[sizeof(T) * N];
143-
constexpr T *storage_data(size_t i) noexcept {
149+
T *storage_data(size_t i) noexcept {
144150
IV_EXPECT(i < N);
145151
return reinterpret_cast<T *>(_d) + i;
146152
}
147-
constexpr const T *storage_data(size_t i) const noexcept {
153+
const T *storage_data(size_t i) const noexcept {
148154
IV_EXPECT(i < N);
149155
return reinterpret_cast<const T *>(_d) + i;
150156
}

0 commit comments

Comments
 (0)