view: allow arbitrary index types for slice and consume
This commit is contained in:
parent
79409eb6fe
commit
f42ae40fcb
13
view.hpp
13
view.hpp
@ -279,11 +279,12 @@ namespace util {
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <typename IndexT>
|
||||
[[nodiscard]] constexpr auto
|
||||
split (int pos) const
|
||||
split (IndexT idx) const
|
||||
{
|
||||
auto last = m_begin;
|
||||
std::advance (last, pos);
|
||||
std::advance (last, idx);
|
||||
return split (last);
|
||||
}
|
||||
|
||||
@ -293,8 +294,9 @@ namespace util {
|
||||
// "abc".slice(0, 3) == "abc"
|
||||
// "abc".slice(0, -1) == "abc"
|
||||
// "abc".slice(0, -2) == "ab"
|
||||
[[nodiscard]] constexpr auto
|
||||
slice (int a, int b) const
|
||||
template <typename IndexA, typename IndexB>
|
||||
[[nodiscard]]constexpr auto
|
||||
slice (IndexA a, IndexB b) const
|
||||
{
|
||||
auto first = m_begin;
|
||||
auto last = m_begin;
|
||||
@ -307,8 +309,9 @@ namespace util {
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
template <typename IndexT>
|
||||
[[nodiscard]] constexpr auto
|
||||
consume (int count) const
|
||||
consume (IndexT count) const
|
||||
{
|
||||
auto [a,b] = split (count);
|
||||
(void)a;
|
||||
|
Loading…
Reference in New Issue
Block a user