map/multi_fixed: add assignment operators

This commit is contained in:
Danny Robson 2021-03-09 12:14:17 +10:00
parent 2d47875b44
commit c7b711550c

View File

@ -84,8 +84,31 @@ namespace cruft::map {
}
}
multi_fixed& operator= (multi_fixed&&) noexcept (std::is_nothrow_move_assignable_v<value_type>) = default;
multi_fixed& operator= (multi_fixed const&) noexcept (std::is_nothrow_assignable_v<value_type>) = default;
multi_fixed&
operator= (multi_fixed &&rhs) noexcept (std::is_nothrow_move_assignable_v<value_type>)
{
for (std::size_t i = 0; i < m_size; ++i)
m_store.data[i].~value_type ();
m_size = 0;
for (m_size = 0; m_size != rhs.m_size; ++m_size)
m_store.data[m_size] = std::move (rhs.m_store.data[m_size]);
rhs.m_size = 0;
return *this;
}
multi_fixed&
operator= (multi_fixed const &rhs) noexcept (std::is_nothrow_assignable_v<value_type, value_type>)
{
for (std::size_t i = 0; i < m_size; ++i)
m_store.data[i].~value_type ();
for (m_size = 0; m_size != rhs.m_size; ++m_size)
m_store.data[m_size] = rhs.m_store.data[m_size];
return *this;
}
iterator begin (void)& { return m_store.data + 0; }
iterator end (void)& { return m_store.data + m_size; }