Lumiera  0.pre.03
»edit your freedom«
IterableDecorator< COR > Class Template Reference

#include "lib/iter-adapter.hpp"

Description

template<class COR>
class lib::IterableDecorator< COR >

Decorator-Adapter to make a »*State Core*« iterable as Lumiera Forward Iterator.

This is a fundamental (and low-level) building block and works essentially the same as IterStateWrapper — with the significant difference however that the Core is mixed in by inheritance and thus its full interface remains publicly accessible. Another notable difference is that this adapter deliberately performs no sanity-checks. This can be dangerous, but allows to use this setup even in performance critical code.

Warning
be sure to understand the consequences of using ´core.yield()´ without checks; an iterator built this way must be checked before each use, unless it is guaranteed to be valid (by contextual knowledge). It might be a good idea to build some safety checks into the Core API functions instead, maybe even just as assertions, or to wrap the Core into CheckedCore for most usages.
Template Parameters
CORtype of the »state core«. The resulting iterator will mix-in this type, and thus inherit properties like copy, move, compare, VTable, „POD-ness“. The COR must implement the following iteration control API:
  1. checkPoint establishes if the given state element represents a valid state
  2. ´iterNextevolves this state by one step (sideeffect) -#yield` realises the given state, exposing a result reference or value Furthermore, COR must be default-constructible in disabled state
Note
the resulting iterator will attempt to yield a reference to type T when possible; but when the wrapped COR::yield() produces a value, this is passed as such, moreover #operator-> becomes disabled then, to prevent taking the address of the (temporary) value!
See also
IterExplorer a pipeline builder framework on top of IterableDecorator
iter-explorer-test.hpp
iter-adaptor-test.cpp

Definition at line 680 of file iter-adapter.hpp.

Public Types

using pointer = typename meta::RefTraits< YieldRes >::Pointer
 
using reference = typename meta::RefTraits< YieldRes >::Reference
 
using value_type = typename meta::RefTraits< YieldRes >::Value
 
using YieldRes = iter::CoreYield< COR >
 

Public Member Functions

template<typename... ARGS>
 IterableDecorator (ARGS &&...init)
 by default, pass anything down for initialisation of the core. More...
 
 IterableDecorator (IterableDecorator &&)=default
 
 IterableDecorator (IterableDecorator const &)=default
 
bool empty () const
 
 ENABLE_USE_IN_STD_RANGE_FOR_LOOPS (IterableDecorator)
 
bool isValid () const
 
 operator bool () const
 
YieldRes operator* () const
 
IterableDecoratoroperator++ ()
 
pointer operator-> () const
 
IterableDecoratoroperator= (IterableDecorator &&)=default
 
IterableDecoratoroperator= (IterableDecorator const &)=default
 

Friends

bool operator!= (IterableDecorator const &il, IterableDecorator const &ir)
 
bool operator== (IterableDecorator const &il, IterableDecorator const &ir)
 Supporting equality comparisons of equivalent iterators (equivalent state core)...
 

Protected Member Functions

void __throw_if_empty () const
 

Private Member Functions

COR & _core ()
 
COR const & _core () const
 

Constructor & Destructor Documentation

◆ IterableDecorator()

IterableDecorator ( ARGS &&...  init)
inline

by default, pass anything down for initialisation of the core.

Note
especially this allows move-initialisation from an existing core.
Remarks
to prevent this rule from "eating" the standard copy operations, and the no-op default ctor, we need to declare them explicitly below.

Definition at line 707 of file iter-adapter.hpp.

+ Inheritance diagram for IterableDecorator< COR >:
+ Collaboration diagram for IterableDecorator< COR >:

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