Merge pull request #13289 from iwubcode/small_vector_clear

Common: add 'clear' function to SmallVector
This commit is contained in:
Jordan Woyak 2025-01-20 15:50:16 -06:00 committed by GitHub
commit 4f912000cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@
#include <array>
#include <cstddef>
#include <type_traits>
#include <utility>
namespace Common
@ -13,6 +14,8 @@ namespace Common
template <typename T, size_t MaxSize>
class SmallVector final
{
static_assert(std::is_standard_layout_v<T> == true, "Type must be a standard layout type");
public:
SmallVector() = default;
explicit SmallVector(size_t size) : m_size(size) {}
@ -40,6 +43,8 @@ public:
size_t size() const { return m_size; }
bool empty() const { return m_size == 0; }
void clear() { m_size = 0; }
private:
std::array<T, MaxSize> m_array{};
size_t m_size = 0;