@brief Resizes the stable array, calling constructors or destructors as needed.
| 59 | |
| 60 | /// @brief Resizes the stable array, calling constructors or destructors as needed. |
| 61 | [[nodiscard]] bool resize(size_t newSize) |
| 62 | { |
| 63 | T* items = data(); |
| 64 | const size_t oldSize = sizeElements; |
| 65 | if (newSize < oldSize) |
| 66 | { |
| 67 | size_t idx = oldSize; |
| 68 | do |
| 69 | { |
| 70 | items[--idx].~T(); |
| 71 | } while (idx != newSize); |
| 72 | } |
| 73 | if (not resizeWithoutInitializing(newSize)) |
| 74 | return false; |
| 75 | if (newSize > oldSize) |
| 76 | { |
| 77 | size_t idx = oldSize; |
| 78 | do |
| 79 | { |
| 80 | placementNew(items[idx++]); |
| 81 | } while (idx != newSize); |
| 82 | } |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | /// @brief Reserves memory for the stable array without initializing elements. |
| 87 | [[nodiscard]] bool reserve(size_t maxNumElements) |
nothing calls this directly
no test coverage detected