template<class POS, class CON>
class lib::IterAdapter< POS, CON >
Adapter for building an implementation of the »Lumiera Forward Iterator« concept.
The "current position" is represented as an opaque element (usually a nested iterator), with callbacks into the controlling container instance to manage this position. This allows to influence and customise the iteration process to a large extent. Basically such an IterAdapter behaves like the similar concept from STL, but
- it is not just a disguised pointer (meaning, it's more expensive)
- it checks validity on every operation and may throw
- it has a distinct back-link to the source container
- the source container needs to support
checkPoint()
and iterNext()
free functions.
- we may need friendship to implement those extension points on the container
- the end-of-iteration can be detected by bool check
- Note
- it is possible to "hide" a smart-ptr within the CON template parameter.
- Template Parameters
-
POS | pointer or similar mutable link to the current value. Will be bool() checked to detect iteration end, end else dereferenced. |
CON | type of the backing container, which needs to implement two extension point functions for iteration control |
- Stipulations
- POS refers to the current position within the data source of this iterator.
- it should be default constructible
- it should be copy constructible
- when IterAdapter is supposed to be assignable, then POS should be
- it should provide embedded typedefs for pointer, reference and value_type, or alternatively resolve these types through specialisation of meta::ValueTypeBinding.
- it should be convertible to the pointer type it declares
- dereferencing should yield a type that is convertible to the reference type
- CON points to the data source of this iterator (typically a data container type) We store a pointer-like backlink to invoke a special iteration control API:
checkPoint
yields true iff the source has yet more result values to yield
iterNext
advances the POS to the next element
- Note
- when POS is just a pointer, we use the pointee as value type
- but when POS is a class, we expect the usual STL style nested typedefs
value_type
, reference
and pointer
- See also
- scoped-ptrvect.hpp usage example
-
value-type-binding.hpp
-
iter-adapter-test.cpp
Definition at line 206 of file iter-adapter.hpp.