Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/iter-adapter.hpp"
Another Lumiera Forward Iterator building block, based on incorporating a state type as »*State Core*«, right into the iterator.
Contrast this to IterAdapter, which refers to a managing container behind the scenes. To the contrary, here all of the state is assumed to live in the custom type embedded into this iterator, accessed and manipulated through a dedicated iteration control API exposed as member functions.
When building iterators with the help of IterStateWrapper or IterableAdapter, it is assumed that the adapted state core type represents a process of state evolution, which reaches a well defined end state eventually, but this end state is also the bottom
checkPoint
establishes if the given state element represents a valid active stateiterNext
evolves this state by one step (sideeffect)yield
realises the given state, yielding an element of result type T ST | type of the »state core«, defaults to T. The resulting iterator will hold an instance of ST, which thus needs to be copyable and default constructible to the extent this is required for the iterator as such. |
T | (optional) result type, usually deduced from ST::yield |
Definition at line 373 of file iter-adapter.hpp.
Public Types | |
using | pointer = typename meta::RefTraits< T >::Pointer |
using | reference = typename meta::RefTraits< T >::Reference |
using | value_type = typename meta::RefTraits< T >::Value |
Public Member Functions | |
IterStateWrapper (ST &&initialState) | |
IterStateWrapper (ST const &initialState) | |
bool | empty () const |
ENABLE_USE_IN_STD_RANGE_FOR_LOOPS (IterStateWrapper) | |
bool | isValid () const |
operator bool () const | |
T | operator* () const |
IterStateWrapper & | operator++ () |
pointer | operator-> () const |
Friends | |
template<class STX , class T1 , class T2 > | |
bool | operator== (IterStateWrapper< STX, T1 > const &, IterStateWrapper< STX, T2 > const &) |
comparison is allowed to access state implementation core | |
Protected Member Functions | |
void | __throw_if_empty () const |
ST & | stateCore () |
allow derived classes to access state representation | |
ST const & | stateCore () const |
Private Attributes | |
ST | core_ |