alloc/raw/linear: enable move operators

This commit is contained in:
Danny Robson 2018-09-21 17:00:56 +10:00
parent dee4a155e3
commit 2e0b51baa4
2 changed files with 25 additions and 4 deletions

View File

@ -22,6 +22,26 @@ linear::linear (cruft::view<std::byte*> _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)

View File

@ -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<std::byte*> _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;
};
}