From 2c0ace639fd2dac0c201e732e3bf9f23b1fc4f51 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 28 Sep 2024 18:32:30 -0400 Subject: [PATCH] remove the base class crap --- CMakeLists.txt | 2 +- include/blt/iterator/zip.h | 141 ------------------------------------- 2 files changed, 1 insertion(+), 142 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9495926..df2a4bf 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.2) +set(BLT_VERSION 1.0.3) set(BLT_TARGET BLT) diff --git a/include/blt/iterator/zip.h b/include/blt/iterator/zip.h index 812b7cd..21bea96 100644 --- a/include/blt/iterator/zip.h +++ b/include/blt/iterator/zip.h @@ -36,147 +36,6 @@ namespace blt template class zip_iterator_storage_rev; - template - class zip_forward_iterator - { - public: - explicit zip_forward_iterator(Iter... iter): iter(std::make_tuple(iter...)) - {} - - std::tuple...> operator*() const - { - return std::apply([](auto& ... i) { return std::make_tuple(*i...); }, iter); - } - - friend bool operator==(const zip_forward_iterator& a, const zip_forward_iterator& b) - { - return a.iter == b.iter; - } - - friend bool operator!=(const zip_forward_iterator& a, const zip_forward_iterator& b) - { - return !(a.iter == b.iter); - } - - zip_forward_iterator& operator++() - { - std::apply([](auto& ... i) { ((++i), ...); }, iter); - return *this; - } - - zip_forward_iterator operator++(int) - { - auto tmp = *this; - ++*this; - return tmp; - } - - auto base() - { - return iter; - } - - protected: - std::tuple iter; - }; - - template - class zip_bidirectional_iterator : public zip_forward_iterator - { - public: - using zip_forward_iterator::zip_forward_iterator; - - zip_bidirectional_iterator& operator--() - { - std::apply([](auto& ... i) { ((--i), ...); }, this->iter); - return *this; - } - - zip_bidirectional_iterator operator--(int) - { - auto tmp = *this; - --*this; - return tmp; - } - }; - - template - class zip_random_access_iterator : public zip_bidirectional_iterator - { - private: - template - static blt::ptrdiff_t sub(const zip_random_access_iterator& a, const zip_random_access_iterator& b, - std::integer_sequence) - { - auto min = std::min(std::get(a.iter) - std::get(b.iter)...); - return min; - } - public: - using zip_bidirectional_iterator::zip_bidirectional_iterator; - - zip_random_access_iterator& operator+=(blt::ptrdiff_t n) - { - std::apply([n](auto& ... i) { ((i += n), ...); }, this->iter); - return *this; - } - - zip_random_access_iterator& operator-=(blt::ptrdiff_t n) - { - std::apply([n](auto& ... i) { ((i -= n), ...); }, this->iter); - return *this; - } - - friend zip_random_access_iterator operator+(const zip_random_access_iterator& a, blt::ptrdiff_t n) - { - return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); - } - - friend zip_random_access_iterator operator+(blt::ptrdiff_t n, const zip_random_access_iterator& a) - { - return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i + n)...}; }, a.iter); - } - - friend zip_random_access_iterator operator-(const zip_random_access_iterator& a, blt::ptrdiff_t n) - { - return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); - } - - friend zip_random_access_iterator operator-(blt::ptrdiff_t n, const zip_random_access_iterator& a) - { - return std::apply([n](auto& ... i) { return zip_random_access_iterator{(i - n)...}; }, a.iter); - } - - friend blt::ptrdiff_t operator-(const zip_random_access_iterator& a, const zip_random_access_iterator& b) - { - return sub(a, b, std::index_sequence_for()); - } - - auto operator[](blt::ptrdiff_t n) const - { - return *(*this + n); - } - - friend bool operator<(const zip_random_access_iterator& a, const zip_random_access_iterator& b) - { - return b - a > 0; - } - - friend bool operator>(const zip_random_access_iterator& a, const zip_random_access_iterator& b) - { - return b < a; - } - - friend bool operator>=(const zip_random_access_iterator& a, const zip_random_access_iterator& b) - { - return !(a < b); // NOLINT - } - - friend bool operator<=(const zip_random_access_iterator& a, const zip_random_access_iterator& b) - { - return !(a > b); // NOLINT - } - }; - template class zip_wrapper {