HeapArray: Add span returners

This commit is contained in:
Stenzek 2024-05-12 22:56:54 +10:00
parent 522c2e3458
commit 117e6be1dc
No known key found for this signature in database
1 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@ -10,6 +10,7 @@
#include <cstdlib>
#include <cstring>
#include <type_traits>
#include <span>
template<typename T, std::size_t SIZE, std::size_t ALIGNMENT = 0>
class FixedHeapArray
@ -73,6 +74,9 @@ public:
void swap(this_type& move) { std::swap(m_data, move.m_data); }
std::span<T, SIZE> span() { return std::span<T, SIZE>(m_data); }
std::span<const T, SIZE> cspan() const { return std::span<const T, SIZE>(m_data); }
this_type& operator=(const this_type& rhs)
{
std::copy(begin(), end(), rhs.cbegin());
@ -314,6 +318,9 @@ public:
move.m_size = 0;
}
std::span<T> span() { return std::span<T>(m_data, m_size); }
std::span<const T> cspan() const { return std::span<const T>(m_data, m_size); }
this_type& operator=(const this_type& rhs)
{
assign(rhs);