TRIQS/itertools 1.3.0
C++ range library
Loading...
Searching...
No Matches
itertools::enum_iter< Iter >

#include <itertools/enumerate.hpp>

Detailed Description

template<typename Iter>
struct itertools::enum_iter< Iter >

Iterator for an itertools::enumerated range.

It stores an iterator of the original range and an index. Incrementing advances the iterator and the index by 1. Dereferencing returns a std::pair consisting of the current index and the current dereferenced value of the original iterator.

See itertools::enumerate(R &&) for more details.

Template Parameters
IterIterator type.

Definition at line 46 of file enumerate.hpp.

Public Member Functions

 enum_iter ()=default
 Default constructor sets the index to zero and default constructs the original iterator.
 
 enum_iter (Iter it)
 Construct an enumerated iterator from a given iterator and set the index to zero.
 
decltype(auto) dereference () const
 Dereference the iterator.
 
void increment ()
 Increment the iterator by incrementing the original iterator and the index.
 
bool operator== (enum_iter const &other) const
 Equal-to operator for two itertools::enum_iter objects.
 
template<typename SentinelIter >
bool operator== (sentinel_t< SentinelIter > const &s) const
 Equal-to operator for a itertools::enum_iter and an itertools::sentinel_t.
 

Public Attributes

long i = 0
 Index for enumerating.
 
Iter it
 Iterator of the original range.
 

Constructor & Destructor Documentation

◆ enum_iter()

template<typename Iter >
itertools::enum_iter< Iter >::enum_iter ( Iter it)
inline

Construct an enumerated iterator from a given iterator and set the index to zero.

Parameters
itIterator of the original range.

Definition at line 60 of file enumerate.hpp.

Member Function Documentation

◆ dereference()

template<typename Iter >
decltype(auto) itertools::enum_iter< Iter >::dereference ( ) const
inlinenodiscard

Dereference the iterator.

Returns
Tuple consisting of the current index and the current dereferenced value of the original iterator.

Definition at line 89 of file enumerate.hpp.

◆ operator==() [1/2]

template<typename Iter >
bool itertools::enum_iter< Iter >::operator== ( enum_iter< Iter > const & other) const
inlinenodiscard

Equal-to operator for two itertools::enum_iter objects.

Parameters
otheritertools::enum_iter to compare with.
Returns
True, if the original iterators are equal.

Definition at line 74 of file enumerate.hpp.

◆ operator==() [2/2]

template<typename Iter >
template<typename SentinelIter >
bool itertools::enum_iter< Iter >::operator== ( sentinel_t< SentinelIter > const & s) const
inlinenodiscard

Equal-to operator for a itertools::enum_iter and an itertools::sentinel_t.

Template Parameters
SentinelIterIterator type of the sentinel.
Parameters
sitertools::sentinel_t to compare with.
Returns
True, if the original iterator is equal to the iterator stored in the sentinel.

Definition at line 83 of file enumerate.hpp.


The documentation for this struct was generated from the following file: