HeapArray: Add span returners
This commit is contained in:
parent
522c2e3458
commit
117e6be1dc
|
@ -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)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <span>
|
||||||
|
|
||||||
template<typename T, std::size_t SIZE, std::size_t ALIGNMENT = 0>
|
template<typename T, std::size_t SIZE, std::size_t ALIGNMENT = 0>
|
||||||
class FixedHeapArray
|
class FixedHeapArray
|
||||||
|
@ -73,6 +74,9 @@ public:
|
||||||
|
|
||||||
void swap(this_type& move) { std::swap(m_data, move.m_data); }
|
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)
|
this_type& operator=(const this_type& rhs)
|
||||||
{
|
{
|
||||||
std::copy(begin(), end(), rhs.cbegin());
|
std::copy(begin(), end(), rhs.cbegin());
|
||||||
|
@ -314,6 +318,9 @@ public:
|
||||||
move.m_size = 0;
|
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)
|
this_type& operator=(const this_type& rhs)
|
||||||
{
|
{
|
||||||
assign(rhs);
|
assign(rhs);
|
||||||
|
|
Loading…
Reference in New Issue