From a58ac18fa09bc9494b82ae9b4721a606cbdc1fbe Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 18 Jun 2024 01:52:02 +0300 Subject: [PATCH] BAN: Add move constructors to ByteSpan --- BAN/include/BAN/ByteSpan.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/BAN/include/BAN/ByteSpan.h b/BAN/include/BAN/ByteSpan.h index 06b53161..94426240 100644 --- a/BAN/include/BAN/ByteSpan.h +++ b/BAN/include/BAN/ByteSpan.h @@ -25,11 +25,26 @@ namespace BAN : m_data(other.data()) , m_size(other.size()) { } + ByteSpanGeneral(ByteSpanGeneral&& other) + : m_data(other.data()) + , m_size(other.size()) + { + other.m_data = nullptr; + other.m_size = 0; + } template ByteSpanGeneral(const ByteSpanGeneral& other) requires(CONST) : m_data(other.data()) , m_size(other.size()) { } + template + ByteSpanGeneral(ByteSpanGeneral&& other) requires(CONST) + : m_data(other.data()) + , m_size(other.size()) + { + other.m_data = nullptr; + other.m_size = 0; + } ByteSpanGeneral(Span other) : m_data(other.data()) , m_size(other.size()) @@ -134,6 +149,8 @@ namespace BAN private: value_type* m_data { nullptr }; size_type m_size { 0 }; + + friend class ByteSpanGeneral; }; using ByteSpan = ByteSpanGeneral;