Py2Cpp 1.6.7
Loading...
Searching...
No Matches
py::detail::EnumerateIterator< T > Struct Template Reference

Iterator for enumerated access to container elements. More...

#include <enumerate.hpp>

Public Types

using TIter = decltype(std::begin(std::declval<T>()))
using iter_ref = typename std::iterator_traits<TIter>::reference

Public Member Functions

auto operator!= (const EnumerateIterator &other) const -> bool
 Check inequality between iterators.
EnumerateIterator & operator++ ()
 Pre-increment operator.
auto operator* () -> std::pair< size_t, iter_ref >
 Dereference operator.

Public Attributes

size_t i
TIter iter

Detailed Description

template<typename T>
struct py::detail::EnumerateIterator< T >

Iterator for enumerated access to container elements.

Provides iterator functionality that yields index-value pairs when iterating over containers, similar to Python's enumerate() function.

Template Parameters
TThe container or range type to enumerate

Member Typedef Documentation

◆ iter_ref

template<typename T>
using py::detail::EnumerateIterator< T >::iter_ref = typename std::iterator_traits<TIter>::reference

◆ TIter

template<typename T>
using py::detail::EnumerateIterator< T >::TIter = decltype(std::begin(std::declval<T>()))

Member Function Documentation

◆ operator!=()

template<typename T>
auto py::detail::EnumerateIterator< T >::operator!= ( const EnumerateIterator< T > & other) const->bool
inline

Check inequality between iterators.

Compares the underlying iterators to determine if they point to different elements.

Parameters
[in]otherThe other iterator to compare with
Returns
true if the iterators are not equal, false otherwise

◆ operator*()

template<typename T>
auto py::detail::EnumerateIterator< T >::operator* ( ) ->std::pair< size_t, iter_ref >
inline

Dereference operator.

Returns a pair containing the current index and a reference to the element.

Returns
std::pair<size_t, iter_ref> Pair of (index, element_reference)

◆ operator++()

template<typename T>
EnumerateIterator & py::detail::EnumerateIterator< T >::operator++ ( )
inline

Pre-increment operator.

Increments both the index counter and the underlying iterator.

Returns
EnumerateIterator& Reference to this iterator

Member Data Documentation

◆ i

template<typename T>
size_t py::detail::EnumerateIterator< T >::i

◆ iter

template<typename T>
TIter py::detail::EnumerateIterator< T >::iter

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