array/parray: add resize function
This commit is contained in:
parent
3e08d64927
commit
04fd13fe42
@ -8,6 +8,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../debug/assert.hpp"
|
||||
#include "../cast.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <cstddef>
|
||||
@ -45,6 +48,16 @@ namespace cruft {
|
||||
parray (parray &&) noexcept = default;
|
||||
parray& operator= (parray &&) noexcept = default;
|
||||
|
||||
// Only allows shrinking currently.
|
||||
void resize (SizeT count)
|
||||
{
|
||||
CHECK_LE (count, m_size);
|
||||
|
||||
for (auto cursor = count; cursor < m_size; ++cursor)
|
||||
m_data[cursor].~DataT ();
|
||||
m_size = count;
|
||||
}
|
||||
|
||||
DataT& operator[] (SizeT idx);
|
||||
const DataT& operator[] (SizeT idx) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user