libzed 1.12.3
A general-purpose library for quick and simple data manipulation.
Loading...
Searching...
No Matches
z::core::generatorIter< T, S > Class Template Reference

Custom iterator for generators to allow for range-based for loops. More...

#include <generator.hpp>

Public Member Functions

 generatorIter (std::function< const std::optional< T >(S &)> lambda, const S &state, bool dummy=false)
 Constructor.
const T & operator* () const
 Get the current value from the generator.
generatorIter & operator++ ()
 Generate the next value.
bool operator!= (const generatorIter &other) const
 Check if the generator can get more data.

Detailed Description

template<typename T, typename S>
class z::core::generatorIter< T, S >

Custom iterator for generators to allow for range-based for loops.

Constructor & Destructor Documentation

◆ generatorIter()

template<typename T, typename S>
z::core::generatorIter< T, S >::generatorIter ( std::function< const std::optional< T >(S &)> lambda,
const S & state,
bool dummy = false )
inlineexplicit

Constructor.

Parameters
lambdaThe generator function.
stateThe state data that may be mutated by the generator function.
dummyIf true, do not generate data. This is here just so range-based loop syntax will work.

Member Function Documentation

◆ operator!=()

template<typename T, typename S>
bool z::core::generatorIter< T, S >::operator!= ( const generatorIter< T, S > & other) const
inline

Check if the generator can get more data.

Returns
false if the generator is finished, true otherwise.

◆ operator*()

template<typename T, typename S>
const T & z::core::generatorIter< T, S >::operator* ( ) const
inline

Get the current value from the generator.

Returns
The last value that was generated.

◆ operator++()

template<typename T, typename S>
generatorIter & z::core::generatorIter< T, S >::operator++ ( )
inline

Generate the next value.

Returns
This iterator after getting the next value from the generator.

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