template<typename T, class ST = T>
class lib::IterStateWrapper< T, ST >
Another Lumiera Forward Iterator building block, based on incorporating a state type right into the iterator.
Contrast this to IterAdapter, which refers to a managing container behind the scenes. Here, all of the state is assumed to live in the custom type embedded into this iterator, accessed and manipulated through a set of free functions, picked up through ADL.
- Assumptions when building iterators based on IterStateWrapper
- There is a custom state representation type ST.
- default constructible
- this default state represents the bottom (invalid) state.
- copyable, because iterators are passed by value
- this type needs to provide an iteration control API with the following operations
checkPoint
establishes if the given state element represents a valid state
iterNext
evolves this state by one step (sideeffect)
yield
realises the given state, yielding an element of result type T&
- Template Parameters
-
T | nominal result type (maybe const, but without reference). The resulting iterator will yield a reference to this 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. |
- See also
- IterableDecorator for variation of the same concept
-
iter-explorer-test.hpp
-
iter-adaptor-test.cpp
Definition at line 351 of file iter-adapter.hpp.