view: add redim operation

This commit is contained in:
Danny Robson 2017-08-31 13:03:19 +10:00
parent a9f8594b26
commit 367fc1dcb1

View File

@ -24,6 +24,7 @@
#include <ostream>
#include <string>
#include <cstring>
#include <stdexcept>
namespace util {
template <typename T>
@ -75,6 +76,14 @@ namespace util {
return std::distance (m_begin, m_end);
}
constexpr auto
redim (int count) const noexcept
{
if (count > size ())
throw std::invalid_argument ("redim to higher size not allowed");
return view { m_begin, m_begin + count };
};
constexpr value_type&
operator[] (size_t idx) noexcept
{