view: don't assert on redim to zero

This commit is contained in:
Danny Robson 2021-11-26 15:23:31 +10:00
parent 0854405b2c
commit 76842f18ba

View File

@ -306,7 +306,9 @@ namespace cruft {
[[nodiscard]] constexpr auto
redim (size_type count) const
{
assert (count > 0);
if constexpr (std::is_signed_v<size_type>)
assert (count >= 0);
if (count > size ())
throw std::invalid_argument ("redim to higher size not allowed");
return view { m_begin, m_begin + count };