mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-11 09:40:17 +00:00
Merge pull request #13289 from iwubcode/small_vector_clear
Common: add 'clear' function to SmallVector
This commit is contained in:
commit
4f912000cd
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
@ -13,6 +14,8 @@ namespace Common
|
|||||||
template <typename T, size_t MaxSize>
|
template <typename T, size_t MaxSize>
|
||||||
class SmallVector final
|
class SmallVector final
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_standard_layout_v<T> == true, "Type must be a standard layout type");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SmallVector() = default;
|
SmallVector() = default;
|
||||||
explicit SmallVector(size_t size) : m_size(size) {}
|
explicit SmallVector(size_t size) : m_size(size) {}
|
||||||
@ -40,6 +43,8 @@ public:
|
|||||||
size_t size() const { return m_size; }
|
size_t size() const { return m_size; }
|
||||||
bool empty() const { return m_size == 0; }
|
bool empty() const { return m_size == 0; }
|
||||||
|
|
||||||
|
void clear() { m_size = 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<T, MaxSize> m_array{};
|
std::array<T, MaxSize> m_array{};
|
||||||
size_t m_size = 0;
|
size_t m_size = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user