Lumiera  0.pre.03
»edit your freedom«
PtrDerefIter< IT > Class Template Reference

#include "lib/iter-adapter-ptr-deref.hpp"

Description

template<class IT>
class lib::PtrDerefIter< IT >

wrapper for an existing Iterator type, automatically dereferencing the output of the former.

For this to work, the "source" iterator is expected to be declared on pointers rather than on values.

Note
bool checkable if and only if source is...

Definition at line 65 of file iter-adapter-ptr-deref.hpp.

Public Types

using ConstIterType = PtrDerefIter< WrappedConstIterType >
 
using IterType = PtrDerefIter< WrappedIterType >
 
using pointer = typename meta::ValueTypeBinding< IT >::value_type
 this iterator adapter is meant to wrap an iterator yielding pointer values
 
using reference = value_type &
 
using value_type = typename std::remove_pointer_t< pointer >
 
using ValueTypeBase = typename std::remove_const_t< value_type >
 
using WrappedConstIterType = typename IterType< IT >::template SimilarIter< const ValueTypeBase **>::Type
 
using WrappedIterType = typename IterType< IT >::template SimilarIter< ValueTypeBase **>::Type
 

Public Member Functions

 PtrDerefIter (IT srcIter)
 PtrDerefIter is always created by wrapping an existing iterator.
 
 PtrDerefIter (PtrDerefIter< WrappedIterType > const &oIter)
 allow copy initialisation also when the wrapped iterator is based on some variation of a pointer. More...
 
bool empty () const
 
 ENABLE_USE_IN_STD_RANGE_FOR_LOOPS (PtrDerefIter)
 
IT const & getBase () const
 access the wrapped implementation iterator
 
bool isValid () const
 
 operator bool () const
 
reference operator* () const
 
PtrDerefIteroperator++ ()
 
pointer operator-> () const
 
PtrDerefIteroperator= (PtrDerefIter< WrappedIterType > const &ref)
 

Static Public Member Functions

static PtrDerefIter build_by_cast (WrappedIterType const &srcIter)
 explicit builder to allow creating a const variant from the basic srcIter type. More...
 
static PtrDerefIter nil ()
 

Private Attributes

IT i_
 nested source iterator
 

Constructor & Destructor Documentation

◆ PtrDerefIter()

PtrDerefIter ( PtrDerefIter< WrappedIterType > const &  oIter)
inline

allow copy initialisation also when the wrapped iterator is based on some variation of a pointer.

Especially, this includes initialisation of the "const variant" from the "normal variant" of PtrDerefIter. Actually, we need to convert in this case by brute force, because indeed (const TY *)* is not assignable from (TY *)* – just we know that our intention is to dereference both levels of pointers, and then the resulting conversion is correct.

Note
in case IT == WrappedIterType, this is just a redefinition of the default copy ctor. In all other cases, this is an additional ctor besides the default copy ctor

Definition at line 117 of file iter-adapter-ptr-deref.hpp.

References PtrDerefIter< IT >::getBase().

+ Here is the call graph for this function:

Member Function Documentation

◆ build_by_cast()

static PtrDerefIter build_by_cast ( WrappedIterType const &  srcIter)
inlinestatic

explicit builder to allow creating a const variant from the basic srcIter type.

Again, the reason necessitating this "backdoor" is that we want to swallow one level of indirection. Generally speaking const T ** is not the same as T * const *, but in our specific case the API ensures that a PtrDerefIter<WrappedConstIterType> only exposes const elements.

Definition at line 143 of file iter-adapter-ptr-deref.hpp.

References PtrDerefIter< IT >::i_.

+ Collaboration diagram for PtrDerefIter< IT >:

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