diff --git a/array/sarray.hpp b/array/sarray.hpp index 561df291..24dd972c 100644 --- a/array/sarray.hpp +++ b/array/sarray.hpp @@ -3,13 +3,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2017 Danny Robson + * Copyright 2017-2019 Danny Robson */ #pragma once #include "../view.hpp" +#include "../iterator/zip.hpp" + #include #include @@ -67,6 +69,23 @@ namespace cruft { sarray (std::begin (_data), std::end (_data)) { ; } + + //--------------------------------------------------------------------- + sarray& operator= (sarray &&rhs) noexcept (std::is_nothrow_move_constructible_v) + { + // Destroy the currently held objects. + for (auto &obj: *this) + obj.~T (); + + // Move-construct the new objects + for (auto [idx, obj]: cruft::iterator::izip (rhs)) + new (&m_data.objects[idx]) T (std::move (obj)); + m_size = rhs.m_size; + + return *this; + } + + //--------------------------------------------------------------------- ~sarray () {