array/sarray: add move constructor

This commit is contained in:
Danny Robson 2019-02-06 17:03:52 +11:00
parent d57a4dddc2
commit 040db9118c

View File

@ -23,6 +23,13 @@ namespace cruft {
template <std::size_t S, typename T> template <std::size_t S, typename T>
class sarray { class sarray {
public: public:
sarray (sarray &&rhs) noexcept (std::is_nothrow_move_constructible_v<T>)
: m_size (rhs.m_size)
{
for (size_t i = 0; i < m_size; ++i)
::new (&m_data.objects[i]) (T) (std::move (rhs[i]));
}
//--------------------------------------------------------------------- //---------------------------------------------------------------------
sarray (sarray const &rhs) sarray (sarray const &rhs)
: sarray (cruft::view (rhs)) : sarray (cruft::view (rhs))