@@ -111,18 +111,15 @@ template <class T, size_t N> struct trivial {
111111 using size_type = smallest_size_t <N>;
112112
113113private:
114- // If value_type is const, then const std::array of non-const elements:
115- using array_based_storage =
116- std::conditional_t <!std::is_const_v<T>, std::array<T, N>,
117- const std::array<std::remove_const_t <T>, N>>;
114+ using array_based_storage = std::array<std::remove_const_t <T>, N>;
118115 alignas (alignof (T)) array_based_storage storage_data_{};
119116 size_type storage_size_ = 0 ;
120117
121118protected:
122119 constexpr const T *storage_data () const noexcept {
123120 return storage_data_.data ();
124121 }
125- constexpr T * storage_data () noexcept { return storage_data_.data (); }
122+ constexpr auto storage_data () noexcept { return storage_data_.data (); }
126123 constexpr size_type storage_size () const noexcept { return storage_size_; }
127124 constexpr void unsafe_set_size (size_t new_size) noexcept {
128125 IV_EXPECT (size_type (new_size) <= N && " new_size out-of-bounds [0, N]" );
@@ -166,17 +163,17 @@ template <class T, size_t N> struct non_trivial {
166163 using size_type = smallest_size_t <N>;
167164
168165private:
169- using byte_based_storage = std::conditional_t <
170- !std::is_const_v<T>, raw_byte_based_storage<T, N>,
171- const raw_byte_based_storage<std::remove_const_t <T>, N>>;
166+ using byte_based_storage = raw_byte_based_storage<std::remove_const_t <T>, N>;
172167 byte_based_storage storage_data_{}; // BUGBUG: test SIMD types
173168 size_type storage_size_ = 0 ;
174169
175170protected:
176171 constexpr const T *storage_data () const noexcept {
177172 return storage_data_.storage_data (0 );
178173 }
179- constexpr T *storage_data () noexcept { return storage_data_.storage_data (0 ); }
174+ constexpr auto storage_data () noexcept {
175+ return storage_data_.storage_data (0 );
176+ }
180177 constexpr size_type storage_size () const noexcept { return storage_size_; }
181178 constexpr void unsafe_set_size (size_t new_size) noexcept {
182179 IV_EXPECT (size_type (new_size) <= N && " new_size out-of-bounds [0, N)" );
@@ -326,7 +323,7 @@ struct inplace_vector_base : private storage::storage_for<T, N> {
326323 requires(std::constructible_from<T, Args...>)
327324 {
328325 IV_EXPECT (size () < capacity () && " inplace_vector out-of-memory" );
329- std::construct_at (end (), std::forward<Args>(args)...);
326+ std::construct_at (storage_data () + size (), std::forward<Args>(args)...);
330327 unsafe_set_size (size () + size_type (1 ));
331328 return this ->back ();
332329 }
0 commit comments