From 117e6be1dc643255db5d3559ce32463d6905e551 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 12 May 2024 22:56:54 +1000 Subject: [PATCH] HeapArray: Add span returners --- src/common/heap_array.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/heap_array.h b/src/common/heap_array.h index 2a2cbc397..474dcf640 100644 --- a/src/common/heap_array.h +++ b/src/common/heap_array.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once @@ -10,6 +10,7 @@ #include #include #include +#include template class FixedHeapArray @@ -73,6 +74,9 @@ public: void swap(this_type& move) { std::swap(m_data, move.m_data); } + std::span span() { return std::span(m_data); } + std::span cspan() const { return std::span(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 span() { return std::span(m_data, m_size); } + std::span cspan() const { return std::span(m_data, m_size); } + this_type& operator=(const this_type& rhs) { assign(rhs);