101 #ifndef LIB_ITER_ADAPTER_H 102 #define LIB_ITER_ADAPTER_H 116 _throwIterExhausted()
119 lumiera::error::LUMIERA_ERROR_ITER_EXHAUST);
124 #define ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(ITER) \ 125 friend ITER begin (ITER const& it){ return it; } \ 126 friend ITER&& begin (ITER&& it) { return static_cast<ITER&&> (it); } \ 127 friend ITER end (ITER const&) { return ITER(); } \ 128 using iterator_category = std::input_iterator_tag; \ 129 using difference_type = size_t; 175 template<
class POS,
class CON>
184 using value_type =
typename _ValTrait::value_type;
185 using reference =
typename _ValTrait::reference;
186 using pointer =
typename _ValTrait::pointer;
202 operator bool()
const 241 return not isValid();
255 return source_ && checkPoint (source_,pos_);
266 iterNext (source_,pos_);
274 using ConRef =
typename meta::RefTraits<CON>::Reference;
278 const ConRef
source()
const {
return unConst(
this)->source_; }
281 resetPos (POS otherPos)
292 _throwIterExhausted();
300 template<
class P1,
class P2,
class CX>
306 template<
class P1,
class P2,
class CON>
309 template<
class P1,
class P2,
class CON>
341 template<
typename T,
class ST =T>
348 typedef T& reference;
349 typedef T value_type;
352 : core_(std::forward<ST>(initialState))
356 : core_(initialState)
364 operator bool()
const 376 return core_.yield();
383 return & core_.yield();
397 return core_.checkPoint();
403 return not isValid();
417 __throw_if_empty()
const 420 _throwIterExhausted();
429 template<
class T1,
class T2,
class STX>
436 template<
class T1,
class T2,
class ST>
440 return (il.empty() and ir.empty())
441 or (il.isValid() and ir.isValid() and il.core_ == ir.core_);
444 template<
class T1,
class T2,
class ST>
448 return not (il == ir);
468 ,
"Lumiera Iterator required as source");
473 return unConst(*
this);
483 return bool(srcIter());
486 typename IT::reference
513 ,
"Adapted type must expose a »state core« API");
518 return unConst(*
this);
522 __throw_if_empty()
const 524 if (not checkPoint())
525 _throwIterExhausted();
532 template<
typename...ARGS>
534 : COR(
std::forward<ARGS>(init)...)
548 return _rawCore().checkPoint();
555 return _rawCore().yield();
562 _rawCore().iterNext();
592 template<
typename T,
class COR>
596 COR & _core() {
return static_cast<COR&
> (*this); }
597 COR
const& _core()
const {
return static_cast<COR const&
> (*this); }
601 __throw_if_empty()
const 604 _throwIterExhausted();
609 typedef T& reference;
610 typedef T value_type;
617 template<
typename...ARGS>
619 : COR(
std::forward<ARGS>(init)...)
631 explicit operator bool()
const {
return isValid(); }
636 return _core().yield();
642 return & _core().yield();
655 return _core().checkPoint();
661 return not isValid();
670 template<
class T1,
class T2>
674 return (il.empty() and ir.empty())
675 or (il.isValid() and ir.isValid() and il._core() == ir._core());
678 template<
class T1,
class T2>
682 return not (il == ir);
715 using pointer =
typename _ValTrait::pointer;
716 using reference =
typename _ValTrait::reference;
719 using value_type =
typename std::remove_reference<reference>::type;
722 RangeIter (IT
const& start, IT
const& end)
743 operator bool()
const 776 return (p_!= IT()) && (p_ != e_);
782 return not isValid();
788 const IT& getEnd()
const {
return e_; }
800 _throwIterExhausted();
807 template<
class I1,
class I2>
810 template<
class I1,
class I2>
825 template<
typename INT>
832 typedef const INT* pointer;
833 typedef const INT& reference;
834 typedef INT value_type;
843 : i_(std::forward<X>(start))
844 , e_(std::forward<X>(end))
855 operator bool()
const 889 return (i_!= INT()) && (i_ < e_);
895 return not isValid();
901 const INT& getEnd()
const {
return e_; }
912 _throwIterExhausted();
919 template<
class I1,
class I2>
922 template<
class I1,
class I2>
928 template<
typename INT>
948 template<
template<
class,
class>
class Iter,
class TY,
class CON>
951 typedef CON Container;
957 typedef Iter<T2,CON> Type;
983 typedef const typename IT::value_type value_type;
984 typedef const typename IT::pointer pointer;
985 typedef const typename IT::reference reference;
992 operator bool()
const 1010 return i_.operator->();
1029 return not isValid();
1046 template<
class I1,
class I2>
1049 template<
class I1,
class I2>
const IT & getPos() const
access wrapped STL iterator
ST & stateCore()
allow derived classes to access state representation
Helper for type rewritings: get the element type for an iterator like entity.
NumIter< INT > eachNum(INT start, INT end)
convenience function to iterate "each number"
CheckedCore(ARGS &&...init)
blindly pass-down any argument...
Adapter to add sanity checks to a »state core«.
Type re-binding helper template for custom containers and adapters.
IterableDecorator(ARGS &&...init)
by default, pass anything down for initialisation of the core.
#define ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(ITER)
use a given Lumiera Forward Iterator in standard "range for loops"
ConRef source()
allow derived classes to access backing container
Adapter to dress up an existing »Lumiera Forward Iterator« as »state core«.
typename std::remove_reference< reference >::type value_type
Implementation namespace for support and library code.
Enumerate all "numbers" within a range.
friend bool operator==(IterAdapter< P1, CX > const &, IterAdapter< P2, CX > const &)
comparison is allowed to access impl iterator
Derived specific exceptions within Lumiera's exception hierarchy.
IT const & getBase() const
access the wrapped implementation iterator
const INT & getPos() const
access wrapped index elements
Another Lumiera Forward Iterator building block, based on incorporating a state type right into the i...
wrapper to expose values as const
RangeIter(I2 const &oIter)
allow copy, when the underlying iterators are compatible or convertible
Lumiera error handling (C++ interface).
IT i_
nested source iterator
bool check() const
ask the controlling container if this position is valid.
Decorator-Adapter to make a »state core« iterable as Lumiera Forward Iterator.
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
void iterate()
ask the controlling container to yield the next position.
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. ...