diff --git a/include/blt/std/ranges.h b/include/blt/std/ranges.h index bb29df4..0b70793 100644 --- a/include/blt/std/ranges.h +++ b/include/blt/std/ranges.h @@ -165,6 +165,41 @@ namespace blt return range_itr(_end - offset, offset == 0); } }; + + template + class itr_offset + { + private: + I begin_; + I end_; + public: + template + itr_offset(I begin, I end, T offset): begin_(begin), end_(end) + { + for (T t = 0; t < offset; t++) + ++begin_; + } + + template + itr_offset(C& container, T offset): begin_(container.begin()), end_(container.end()) + { + for (T t = 0; t < offset; t++) + ++begin_; + } + + auto begin() + { + return begin_; + } + + auto end() + { + return end_; + } + }; + + template + itr_offset(C, T) -> itr_offset; } #endif //BLT_RANGES_H