remove the base class crap

v1
Brett 2024-09-28 18:32:30 -04:00
parent 7580fa544a
commit 2c0ace639f
2 changed files with 1 additions and 142 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 1.0.2) set(BLT_VERSION 1.0.3)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -36,147 +36,6 @@ namespace blt
template<typename Tag, typename... Iter> template<typename Tag, typename... Iter>
class zip_iterator_storage_rev; class zip_iterator_storage_rev;
template<typename... Iter>
class zip_forward_iterator
{
public:
explicit zip_forward_iterator(Iter... iter): iter(std::make_tuple(iter...))
{}
std::tuple<blt::meta::deref_return_t<Iter>...> 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...> iter;
};
template<typename... Iter>
class zip_bidirectional_iterator : public zip_forward_iterator<Iter...>
{
public:
using zip_forward_iterator<Iter...>::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<typename... Iter>
class zip_random_access_iterator : public zip_bidirectional_iterator<Iter...>
{
private:
template<typename T, T... n>
static blt::ptrdiff_t sub(const zip_random_access_iterator& a, const zip_random_access_iterator& b,
std::integer_sequence<T, n...>)
{
auto min = std::min(std::get<n>(a.iter) - std::get<n>(b.iter)...);
return min;
}
public:
using zip_bidirectional_iterator<Iter...>::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<Iter...>());
}
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<typename... Iter> template<typename... Iter>
class zip_wrapper<std::forward_iterator_tag, Iter...> class zip_wrapper<std::forward_iterator_tag, Iter...>
{ {