view: add increment and decrement operators
This commit is contained in:
parent
452328957d
commit
462e2e6ad1
31
view.hpp
31
view.hpp
@ -22,6 +22,9 @@
|
||||
#include <stdexcept>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <concepts>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace cruft {
|
||||
template <typename BeginT, typename EndT = BeginT>
|
||||
@ -729,6 +732,34 @@ namespace cruft {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <std::bidirectional_iterator IteratorT>
|
||||
cruft::view<IteratorT>&
|
||||
operator-= (
|
||||
cruft::view<IteratorT> &val,
|
||||
typename std::iterator_traits<IteratorT>::difference_type offset
|
||||
) {
|
||||
return val = {
|
||||
val.begin () - offset,
|
||||
val.end () - offset
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
template <std::incrementable IteratorT>
|
||||
cruft::view<IteratorT>&
|
||||
operator+= (
|
||||
cruft::view<IteratorT> &val,
|
||||
typename std::iterator_traits<IteratorT>::difference_type offset
|
||||
) {
|
||||
return val = {
|
||||
val.begin () + offset,
|
||||
val.end () + offset
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename BeginT, typename EndT, typename FunctionT>
|
||||
view<BeginT, EndT>
|
||||
|
Loading…
Reference in New Issue
Block a user