|
40 | 40 |
|
41 | 41 | // If tight, it grows strictly as much as needed. |
42 | 42 | // Otherwise, it grows exponentially (the default and what you want in most cases). |
43 | | -// force_trivial is used to avoid T's default value on resize, for improved performance. |
44 | | -// This requires T to be trivially destructible. |
45 | 43 | template <typename T, typename U = uint32_t, bool force_trivial = false, bool tight = false> |
46 | 44 | class LocalVector { |
| 45 | + static_assert(!force_trivial, "force_trivial is no longer supported. Use resize_uninitialized instead."); |
| 46 | + |
47 | 47 | private: |
48 | 48 | U count = 0; |
49 | 49 | U capacity = 0; |
@@ -182,14 +182,13 @@ class LocalVector { |
182 | 182 |
|
183 | 183 | /// Resize the vector. |
184 | 184 | /// Elements are initialized (or not) depending on what the default C++ behavior for T is. |
185 | | - /// Note: If force_trivial is set, this will behave like resize_trivial instead. |
| 185 | + /// Note: If force_trivial is set, this will behave like resize_uninitialized instead. |
186 | 186 | void resize(U p_size) { |
187 | | - // Don't init when trivially constructible, or force_trivial is set. |
188 | | - _resize<!force_trivial && !std::is_trivially_constructible_v<T>>(p_size); |
| 187 | + // Don't init when trivially constructible. |
| 188 | + _resize<!std::is_trivially_constructible_v<T>>(p_size); |
189 | 189 | } |
190 | 190 |
|
191 | 191 | /// Resize and set all values to 0 / false / nullptr. |
192 | | - /// This is only available for zero constructible types. |
193 | 192 | _FORCE_INLINE_ void resize_initialized(U p_size) { _resize<true>(p_size); } |
194 | 193 |
|
195 | 194 | /// Resize and set all values to 0 / false / nullptr. |
@@ -410,8 +409,8 @@ class LocalVector { |
410 | 409 | } |
411 | 410 | }; |
412 | 411 |
|
413 | | -template <typename T, typename U = uint32_t, bool force_trivial = false> |
414 | | -using TightLocalVector = LocalVector<T, U, force_trivial, true>; |
| 412 | +template <typename T, typename U = uint32_t> |
| 413 | +using TightLocalVector = LocalVector<T, U, false, true>; |
415 | 414 |
|
416 | 415 | // Zero-constructing LocalVector initializes count, capacity and data to 0 and thus empty. |
417 | 416 | template <typename T, typename U, bool force_trivial, bool tight> |
|
0 commit comments