From 2e0b51baa46c43abf5940a1db77e885eee298839 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 21 Sep 2018 17:00:56 +1000 Subject: [PATCH] alloc/raw/linear: enable move operators --- alloc/raw/linear.cpp | 20 ++++++++++++++++++++ alloc/raw/linear.hpp | 9 +++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/alloc/raw/linear.cpp b/alloc/raw/linear.cpp index 4928964b..85661786 100644 --- a/alloc/raw/linear.cpp +++ b/alloc/raw/linear.cpp @@ -22,6 +22,26 @@ linear::linear (cruft::view _data): { ; } +/////////////////////////////////////////////////////////////////////////////// +linear::linear (linear &&rhs) + : m_begin (std::exchange (rhs.m_begin, nullptr)) + , m_end (std::exchange (rhs.m_end, nullptr)) + , m_cursor (std::exchange (rhs.m_cursor, nullptr)) +{ ; } + + +//----------------------------------------------------------------------------- +linear& +linear::operator= (cruft::alloc::raw::linear &&rhs) +{ + m_begin = std::exchange (rhs.m_begin, nullptr); + m_end = std::exchange (rhs.m_end, nullptr); + m_cursor = std::exchange (rhs.m_cursor, nullptr); + + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// std::byte* linear::data (void) diff --git a/alloc/raw/linear.hpp b/alloc/raw/linear.hpp index 61170e04..ab2e19c1 100644 --- a/alloc/raw/linear.hpp +++ b/alloc/raw/linear.hpp @@ -21,9 +21,10 @@ namespace cruft::alloc::raw { class linear { public: linear (const linear&) = delete; - linear (linear&&) = delete; linear& operator= (const linear&) = delete; - linear& operator= (linear&&) = delete; + + linear (linear&&); + linear& operator= (linear&&); linear (cruft::view _data); @@ -98,8 +99,8 @@ namespace cruft::alloc::raw { size_t remain (void) const; protected: - std::byte *const m_begin; - std::byte *const m_end; + std::byte *m_begin; + std::byte *m_end; std::byte *m_cursor; }; }