Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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) -#yieldrealises 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 \a T when possible; but when the wrappedCOR::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 681 of file iter-adapter.hpp.

Public Types

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

Public Member Functions

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

Friends

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

Protected Member Functions

void __throw_if_empty () const
 

Private Member Functions

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

Constructor & Destructor Documentation

◆ IterableDecorator() [1/4]

template<class COR >
template<typename... ARGS>
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 708 of file iter-adapter.hpp.

◆ IterableDecorator() [2/4]

template<class COR >
IterableDecorator ( )
default

◆ IterableDecorator() [3/4]

template<class COR >
IterableDecorator ( IterableDecorator< COR > &&  )
default

◆ IterableDecorator() [4/4]

template<class COR >
IterableDecorator ( IterableDecorator< COR > const &  )
default

Member Typedef Documentation

◆ YieldRes

template<class COR >
using YieldRes = iter::CoreYield<COR>

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

◆ value_type

template<class COR >
using value_type = meta::RefTraits<YieldRes>::Value

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

◆ reference

template<class COR >
using reference = meta::RefTraits<YieldRes>::Reference

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

◆ pointer

template<class COR >
using pointer = meta::RefTraits<YieldRes>::Pointer

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

Member Function Documentation

◆ _core() [1/2]

template<class COR >
COR & _core ( )
inlineprivate

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

Referenced by IterableDecorator< COR >::isValid(), IterableDecorator< COR >::operator*(), IterableDecorator< COR >::operator++(), and IterableDecorator< COR >::operator->().

+ Here is the caller graph for this function:

◆ _core() [2/2]

template<class COR >
COR const & _core ( ) const
inlineprivate

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

◆ __throw_if_empty()

template<class COR >
void __throw_if_empty ( ) const
inlineprotected

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

References IterableDecorator< COR >::isValid().

+ Here is the call graph for this function:

◆ operator=() [1/2]

template<class COR >
IterableDecorator & operator= ( IterableDecorator< COR > &&  )
default

◆ operator=() [2/2]

template<class COR >
IterableDecorator & operator= ( IterableDecorator< COR > const &  )
default

◆ operator bool()

template<class COR >
operator bool ( ) const
inlineexplicit

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

References IterableDecorator< COR >::isValid().

+ Here is the call graph for this function:

◆ operator*()

template<class COR >
YieldRes operator* ( ) const
inline

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

References IterableDecorator< COR >::_core().

+ Here is the call graph for this function:

◆ operator->()

template<class COR >
pointer operator-> ( ) const
inline

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

References IterableDecorator< COR >::_core().

+ Here is the call graph for this function:

◆ operator++()

template<class COR >
IterableDecorator & operator++ ( )
inline

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

References IterableDecorator< COR >::_core().

+ Here is the call graph for this function:

◆ isValid()

template<class COR >
bool isValid ( ) const
inline

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

References IterableDecorator< COR >::_core().

Referenced by IterableDecorator< COR >::__throw_if_empty(), IterableDecorator< COR >::empty(), and IterableDecorator< COR >::operator bool().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

template<class COR >
bool empty ( ) const
inline

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

References IterableDecorator< COR >::isValid().

+ Here is the call graph for this function:

◆ ENABLE_USE_IN_STD_RANGE_FOR_LOOPS()

template<class COR >
ENABLE_USE_IN_STD_RANGE_FOR_LOOPS ( IterableDecorator< COR >  )

Friends And Related Symbol Documentation

◆ operator==

template<class COR >
bool operator== ( IterableDecorator< COR > const &  il,
IterableDecorator< COR > const &  ir 
)
friend

Supporting equality comparisons of equivalent iterators (equivalent state core)...

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

◆ operator!=

template<class COR >
bool operator!= ( IterableDecorator< COR > const &  il,
IterableDecorator< COR > const &  ir 
)
friend

Definition at line 772 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: