#include <py2cpp/enumerate.hpp>
template<typename T>
EnumerateIterator struct
Template parameters | |
---|---|
T |
The code defines a struct called EnumerateIterator
that is used to iterate over a container or range and provide the index of each element in the iteration.
Public types
Public functions
- auto operator!=(const EnumerateIterator& other) const -> bool -> auto
- Not equal to.
- auto operator++() -> EnumerateIterator&
- The
operator++()
function is an overloaded operator that increments theEnumerateIterator
object. It increases the value of thei
member variable by 1 and advances theiter
member variable to the next element in the iteration. It then returns a reference to the updatedEnumerateIterator
object. - auto operator*() -> std::pair< size_t, iter_ref > -> auto
- The
operator*()
function is an overloaded operator that returns the current element in the iteration as astd::pair<size_t, iter_ref>
. Thesize_t
value represents the index of the element, and theiter_ref
value represents a reference to the element itself. This allows you to access both the index and the element in a single expression when using theenumerate()
function.
Public variables
Function documentation
template<typename T>
auto py:: detail:: EnumerateIterator<T>:: operator!=(const EnumerateIterator& other) const -> bool
Not equal to.
Parameters | |
---|---|
other in | |
Returns | true |
The operator!=
function is an overloaded operator that checks for inequality between two EnumerateIterator
objects. It compares the iter
member of the current object with the iter
member of the other
object. If they are not equal, it returns true
, indicating that the two iterators are not pointing to the same element. Otherwise, it returns false
, indicating that the two iterators are equal.
template<typename T>
EnumerateIterator& py:: detail:: EnumerateIterator<T>:: operator++()
The operator++()
function is an overloaded operator that increments the EnumerateIterator
object. It increases the value of the i
member variable by 1 and advances the iter
member variable to the next element in the iteration. It then returns a reference to the updated EnumerateIterator
object.
Returns | EnumerateIterator& |
---|
template<typename T>
auto py:: detail:: EnumerateIterator<T>:: operator*() -> std::pair< size_t, iter_ref >
The operator*()
function is an overloaded operator that returns the current element in the iteration as a std::pair<size_t, iter_ref>
. The size_t
value represents the index of the element, and the iter_ref
value represents a reference to the element itself. This allows you to access both the index and the element in a single expression when using the enumerate()
function.
Returns | std::pair<size_t, iter_ref> |
---|