array/parray: add erase function
This commit is contained in:
parent
bca58bf352
commit
07840dbc54
@ -80,6 +80,30 @@ namespace cruft {
|
||||
SizeT size (void) const;
|
||||
bool empty (void) const { return size () == 0; }
|
||||
|
||||
template <
|
||||
typename T = DataT,
|
||||
typename = std::enable_if_t<std::is_move_assignable_v<T>>
|
||||
>
|
||||
DataT*
|
||||
erase (DataT *first, DataT *last)
|
||||
{
|
||||
DataT *newend = std::move (last, m_data + m_size, first);
|
||||
for (auto cursor = newend; cursor != end (); ++cursor)
|
||||
cursor->~DataT ();
|
||||
m_size = cruft::cast::lossless<SizeT> (newend - m_data);
|
||||
return newend;
|
||||
}
|
||||
|
||||
template <
|
||||
typename T = DataT,
|
||||
typename = std::enable_if_t<std::is_move_assignable_v<T>>
|
||||
>
|
||||
DataT*
|
||||
erase (DataT *item)
|
||||
{
|
||||
return erase (item, item + 1);
|
||||
}
|
||||
|
||||
private:
|
||||
SizeT m_size;
|
||||
DataT *m_data;
|
||||
|
Loading…
Reference in New Issue
Block a user