LdsGen 1.2.6
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ldsgen::GeneratorIterable< Derived, Value > Class Template Reference

CRTP mixin adding STL iterator support to a GeneratorBase. More...

#include <lds.hpp>

Inheritance diagram for ldsgen::GeneratorIterable< Derived, Value >:
[legend]
Collaboration diagram for ldsgen::GeneratorIterable< Derived, Value >:
[legend]

Public Member Functions

auto begin () -> GeneratorIterator< Derived, Value >
 Get iterator to beginning.
 
auto end () const -> GeneratorIterator< Derived, Value >
 Get iterator to end (infinite sequence)
 
- Public Member Functions inherited from ldsgen::GeneratorBase< Derived, Value >
auto pop () -> Value
 Generate the next value in the sequence (advances state).
 
auto peek () -> Value
 Peek at the next value without advancing state.
 
auto skip (unsigned int n) -> void
 Skip n values in the sequence.
 
auto reseed (const unsigned long &seed) -> void
 Reset the generator to a specific seed value.
 
auto get_index () const -> unsigned long
 Get current index in the sequence.
 

Additional Inherited Members

- Protected Attributes inherited from ldsgen::GeneratorBase< Derived, Value >
std::atomic< unsigned long > count_ {0}
 Current sequence index (single source of state)
 

Detailed Description

template<typename Derived, typename Value>
class ldsgen::GeneratorIterable< Derived, Value >

CRTP mixin adding STL iterator support to a GeneratorBase.

Provides begin()/end() so generators can be consumed with range-for, std::begin/ std::end and STL algorithms. Combined with GeneratorIterator, this realizes the Iterator pattern for every generator without repeating the iterator boilerplate.

Template Parameters
DerivedThe CRTP-derived generator class.
ValueThe value type produced by the generator.

Member Function Documentation

◆ begin()

template<typename Derived , typename Value >
auto ldsgen::GeneratorIterable< Derived, Value >::begin ( ) -> GeneratorIterator<Derived, Value>
inline

Get iterator to beginning.

Returns
GeneratorIterator<Derived, Value>

◆ end()

template<typename Derived , typename Value >
auto ldsgen::GeneratorIterable< Derived, Value >::end ( ) const -> GeneratorIterator<Derived, Value>
inline

Get iterator to end (infinite sequence)

For infinite sequences, you typically use begin() + n to get a specific position

Returns
GeneratorIterator<Derived, Value>

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