@@ -112,18 +112,15 @@ template <class T, size_t N> struct trivial {
112112 using size_type = smallest_size_t <N>;
113113
114114private:
115- // If value_type is const, then const std::array of non-const elements:
116- using array_based_storage =
117- std::conditional_t <!std::is_const_v<T>, std::array<T, N>,
118- const std::array<std::remove_const_t <T>, N>>;
115+ using array_based_storage = std::array<std::remove_const_t <T>, N>;
119116 alignas (alignof (T)) array_based_storage storage_data_{};
120117 size_type storage_size_ = 0 ;
121118
122119protected:
123120 constexpr const T *storage_data () const noexcept {
124121 return storage_data_.data ();
125122 }
126- constexpr T * storage_data () noexcept { return storage_data_.data (); }
123+ constexpr auto storage_data () noexcept { return storage_data_.data (); }
127124 constexpr size_type storage_size () const noexcept { return storage_size_; }
128125 constexpr void unsafe_set_size (size_t new_size) noexcept {
129126 IV_EXPECT (size_type (new_size) <= N && " new_size out-of-bounds [0, N]" );
@@ -161,17 +158,17 @@ template <class T, size_t N> struct non_trivial {
161158 using size_type = smallest_size_t <N>;
162159
163160private:
164- using byte_based_storage = std::conditional_t <
165- !std::is_const_v<T>, raw_byte_based_storage<T, N>,
166- const raw_byte_based_storage<std::remove_const_t <T>, N>>;
161+ using byte_based_storage = raw_byte_based_storage<std::remove_const_t <T>, N>;
167162 byte_based_storage storage_data_{}; // BUGBUG: test SIMD types
168163 size_type storage_size_ = 0 ;
169164
170165protected:
171166 constexpr const T *storage_data () const noexcept {
172167 return storage_data_.storage_data (0 );
173168 }
174- constexpr T *storage_data () noexcept { return storage_data_.storage_data (0 ); }
169+ constexpr auto storage_data () noexcept {
170+ return storage_data_.storage_data (0 );
171+ }
175172 constexpr size_type storage_size () const noexcept { return storage_size_; }
176173 constexpr void unsafe_set_size (size_t new_size) noexcept {
177174 IV_EXPECT (size_type (new_size) <= N && " new_size out-of-bounds [0, N)" );
@@ -323,7 +320,7 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
323320 requires(std::constructible_from<T, Args...>)
324321 {
325322 IV_EXPECT (size () < capacity () && " inplace_vector out-of-memory" );
326- std::construct_at (end (), std::forward<Args>(args)...);
323+ std::construct_at (storage_data () + size (), std::forward<Args>(args)...);
327324 unsafe_set_size (size () + size_type (1 ));
328325 return this ->back ();
329326 }
0 commit comments