| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/pythran/pythonic/types/ |
Upload File : |
#ifndef PYTHONIC_TYPES_GENERATOR_HPP
#define PYTHONIC_TYPES_GENERATOR_HPP
#include "pythonic/include/types/generator.hpp"
#include "pythonic/builtins/StopIteration.hpp"
#include <iterator>
PYTHONIC_NS_BEGIN
namespace types
{
template <class T>
generator_iterator<T>::generator_iterator()
: the_generator()
{
the_generator.__generator_state = -1;
} // this represents the end
template <class T>
generator_iterator<T>::generator_iterator(T const &a_generator)
: the_generator(a_generator)
{
}
template <class T>
generator_iterator<T> &generator_iterator<T>::operator++()
{
try {
the_generator.next();
} catch (types::StopIteration const &) {
the_generator.__generator_state = -1;
}
return *this;
}
template <class T>
typename T::result_type generator_iterator<T>::operator*() const
{
return *the_generator;
}
template <class T>
bool generator_iterator<T>::
operator!=(generator_iterator<T> const &other) const
{
assert(other.the_generator.__generator_state == -1 ||
the_generator.__generator_state == -1);
return the_generator.__generator_state !=
other.the_generator.__generator_state;
}
template <class T>
bool generator_iterator<T>::
operator==(generator_iterator<T> const &other) const
{
assert(other.the_generator.__generator_state == -1 ||
the_generator.__generator_state == -1);
return the_generator.__generator_state ==
other.the_generator.__generator_state;
}
template <class T>
bool generator_iterator<T>::
operator<(generator_iterator<T> const &other) const
{
assert(other.the_generator.__generator_state == -1 ||
the_generator.__generator_state == -1);
return the_generator.__generator_state !=
other.the_generator.__generator_state;
}
}
PYTHONIC_NS_END
#endif