diff --git a/array/parray.hpp b/array/parray.hpp index a058fe2c..c468c4d4 100644 --- a/array/parray.hpp +++ b/array/parray.hpp @@ -8,6 +8,9 @@ #pragma once +#include "../debug/assert.hpp" +#include "../cast.hpp" + #include #include #include @@ -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;