#ifndef PYTHONIC_ITERTOOLS_COUNT_HPP #define PYTHONIC_ITERTOOLS_COUNT_HPP #include "pythonic/include/itertools/count.hpp" #include "pythonic/utils/functor.hpp" #include PYTHONIC_NS_BEGIN namespace itertools { namespace details { template count_iterator::count_iterator(T value, T step) : value(value), step(step) { } template T count_iterator::operator*() const { return value; } template count_iterator &count_iterator::operator++() { value += step; return *this; } template count_iterator &count_iterator::operator+=(long n) { value += step * n; return *this; } template bool count_iterator::operator!=(count_iterator const &other) const { return value != other.value; } template bool count_iterator::operator==(count_iterator const &other) const { return value == other.value; } template bool count_iterator::operator<(count_iterator const &other) const { return value < other.value; } template long count_iterator::operator-(count_iterator const &other) const { return (value - other.value) / step; } template count::count(T value, T step) : count_iterator(value, step) { } template typename count::iterator &count::begin() { return *this; } template typename count::iterator const &count::begin() const { return *this; } template typename count::iterator count::end() const { return {std::numeric_limits::max(), count_iterator::step}; } } template details::count::type> count(T0 start, T1 step) { using return_t = typename __combined::type; return {static_cast(start), static_cast(step)}; } details::count count() { return {0, 1}; } } PYTHONIC_NS_END #endif