From 93ff30f53a5921d2543386f31c86957de287a68c Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 3 Mar 2023 13:15:51 +0100 Subject: [PATCH] Core/ByteArray: Add constructor taking the container by value Allowing to move the content --- include/Nazara/Core/ByteArray.hpp | 1 + include/Nazara/Core/ByteArray.inl | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/Nazara/Core/ByteArray.hpp b/include/Nazara/Core/ByteArray.hpp index 555d18f9d..75b3875ee 100644 --- a/include/Nazara/Core/ByteArray.hpp +++ b/include/Nazara/Core/ByteArray.hpp @@ -40,6 +40,7 @@ namespace Nz inline explicit ByteArray(size_type n); inline ByteArray(const void* buffer, size_type n); inline ByteArray(size_type n, value_type value); + inline explicit ByteArray(Container container); template ByteArray(InputIterator first, InputIterator last); ByteArray(const ByteArray& other) = default; ByteArray(ByteArray&& other) noexcept = default; diff --git a/include/Nazara/Core/ByteArray.inl b/include/Nazara/Core/ByteArray.inl index 31b71ce39..716867182 100644 --- a/include/Nazara/Core/ByteArray.inl +++ b/include/Nazara/Core/ByteArray.inl @@ -46,6 +46,11 @@ namespace Nz { } + inline ByteArray::ByteArray(Container container) : + m_array(std::move(container)) + { + } + /*! * \brief Constructs a ByteArray object from two iterators * @@ -593,6 +598,15 @@ namespace Nz return m_array.rend(); } + /*! + * \brief Returns a reversed iterator pointing to the end of the string + * \return End of the string + */ + inline ByteArray::const_reverse_iterator ByteArray::rend() const noexcept + { + return m_array.rend(); + } + /*! * \brief Gets the size of the byte array * \return Size of the byte array