diff --git a/CMakeLists.txt b/CMakeLists.txt index e3365ca..5cd6c1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 1.0.4) +set(BLT_VERSION 1.0.5) set(BLT_TARGET BLT) diff --git a/include/blt/iterator/zip.h b/include/blt/iterator/zip.h index aa6cf47..a75ff8e 100644 --- a/include/blt/iterator/zip.h +++ b/include/blt/iterator/zip.h @@ -72,7 +72,7 @@ namespace blt return tmp; } - auto base() + auto raw_tuple() { return iter; } @@ -205,10 +205,12 @@ namespace blt } }; + BLT_META_MAKE_FUNCTION_CHECK(base); + template auto get_base(Iter iter) { - if constexpr (meta::is_reverse_iterator_v) + if constexpr (has_func_base_v) { return std::move(iter).base(); } else @@ -252,7 +254,7 @@ namespace blt if constexpr (check) { return Derived{get_base(begin), - get_base(begin + std::min(n, static_cast(std::distance(begin, end))))}; + get_base(begin + std::min(static_cast(n), std::distance(begin, end)))}; } else { return Derived{get_base(begin), get_base(begin + n)}; @@ -267,6 +269,48 @@ namespace blt auto take_or(blt::size_t n) { return take_base(n); } }; + + template + class skip_impl + { + private: + template + auto skip_base(blt::size_t n) + { + auto* d = static_cast(this); + auto begin = d->begin(); + auto end = d->end(); + + if constexpr (std::is_same_v) + { + if constexpr (check) + { + return Derived{begin + std::min(static_cast(n), std::distance(begin, end))}; + } else + { + return Derived{begin + n, end}; + } + } else + { + for (blt::size_t i = 0; i < n; i++) + { + if constexpr (check){ + if (begin == end) + break; + } + ++begin; + } + return Derived{begin, end}; + } + } + + public: + void skip(blt::size_t n) + { return skip_base(n); } + + void skip_or(blt::size_t n) + { return skip_base(n); } + }; } template