view: use trivial constructors and assignment

this allows us to fulfil the requirements of TriviallyCopyable which is
useful particularly in dumb allocators and job queues.
This commit is contained in:
Danny Robson 2018-03-23 14:10:57 +11:00
parent 36f4ba035c
commit 58843fb0c7

View File

@ -155,20 +155,11 @@ namespace util {
//--------------------------------------------------------------------- //---------------------------------------------------------------------
constexpr constexpr view (const view &) noexcept = default;
view (const view &rhs) noexcept: constexpr view (view &&) noexcept = default;
view {rhs.m_begin, rhs.m_end}
{ ; }
view& operator= (const view &rhs) noexcept = default;
//--------------------------------------------------------------------- view& operator= (view &&rhs) noexcept = default;
// technically we could get away without explicitly defining a move
// constructor here, but by nulling rhs we can more easily use this
// class as a base for unique owning pointers without exposing the
// begin/end data members to them directly.
constexpr view (view &&rhs) noexcept:
view {std::move (rhs.m_begin), std::move (rhs.m_end)}
{ ; }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -225,30 +216,6 @@ namespace util {
{ ; } { ; }
//---------------------------------------------------------------------
view&
operator= (const view &rhs) noexcept
{
m_begin = rhs.m_begin;
m_end = rhs.m_end;
return *this;
}
//---------------------------------------------------------------------
view&
operator= (view &&rhs) noexcept
{
m_begin = rhs.m_begin;
m_end = rhs.m_end;
rhs.m_begin = BeginT{};
rhs.m_end = EndT{};
return *this;
};
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
constexpr BeginT begin (void) noexcept { return m_begin; } constexpr BeginT begin (void) noexcept { return m_begin; }
constexpr EndT end (void) noexcept { return m_end; } constexpr EndT end (void) noexcept { return m_end; }