view: add redim operation
This commit is contained in:
parent
a9f8594b26
commit
367fc1dcb1
9
view.hpp
9
view.hpp
@ -24,6 +24,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -75,6 +76,14 @@ namespace util {
|
|||||||
return std::distance (m_begin, m_end);
|
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&
|
constexpr value_type&
|
||||||
operator[] (size_t idx) noexcept
|
operator[] (size_t idx) noexcept
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user