Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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 56 of file iter-adapter-ptr-deref.hpp.

Public Types

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

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.
 
static PtrDerefIter nil ()
 

Public Member Functions

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

Private Attributes

IT i_
 nested source iterator
 

Constructor & Destructor Documentation

◆ PtrDerefIter() [1/3]

template<class IT >
PtrDerefIter ( IT  srcIter)
inlineexplicit

PtrDerefIter is always created by wrapping an existing iterator.

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

◆ PtrDerefIter() [2/3]

template<class IT >
PtrDerefIter ( )
inline

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

Referenced by PtrDerefIter< IT >::build_by_cast(), and PtrDerefIter< IT >::nil().

+ Here is the caller graph for this function:

◆ PtrDerefIter() [3/3]

template<class IT >
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 108 of file iter-adapter-ptr-deref.hpp.

Member Typedef Documentation

◆ pointer

template<class IT >
using pointer = meta::ValueTypeBinding<IT>::value_type

this iterator adapter is meant to wrap an iterator yielding pointer values

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

◆ value_type

template<class IT >
using value_type = std::remove_pointer_t<pointer>

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

◆ reference

template<class IT >
using reference = value_type&

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

◆ ValueTypeBase

template<class IT >
using ValueTypeBase = std::remove_const_t<value_type>

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

◆ WrappedIterType

template<class IT >
using WrappedIterType = IterType<IT>::template SimilarIter< ValueTypeBase* * >::Type

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

◆ WrappedConstIterType

template<class IT >
using WrappedConstIterType = IterType<IT>::template SimilarIter<const ValueTypeBase* * >::Type

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

◆ IterType

template<class IT >
using IterType = PtrDerefIter<WrappedIterType>

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

◆ ConstIterType

template<class IT >
using ConstIterType = PtrDerefIter<WrappedConstIterType>

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

Member Function Documentation

◆ ENABLE_USE_IN_STD_RANGE_FOR_LOOPS()

template<class IT >
ENABLE_USE_IN_STD_RANGE_FOR_LOOPS ( PtrDerefIter< IT >  )

◆ operator=()

template<class IT >
PtrDerefIter & operator= ( PtrDerefIter< WrappedIterType > const &  ref)
inline

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

References PtrDerefIter< IT >::getBase(), and PtrDerefIter< IT >::i_.

+ Here is the call graph for this function:

◆ operator bool()

template<class IT >
operator bool ( ) const
inlineexplicit

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

References PtrDerefIter< IT >::isValid().

+ Here is the call graph for this function:

◆ build_by_cast()

template<class IT >
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 134 of file iter-adapter-ptr-deref.hpp.

References PtrDerefIter< IT >::PtrDerefIter().

+ Here is the call graph for this function:

◆ nil()

template<class IT >
static PtrDerefIter nil ( )
inlinestatic

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

References PtrDerefIter< IT >::PtrDerefIter().

+ Here is the call graph for this function:

◆ operator*()

template<class IT >
reference operator* ( ) const
inline

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

◆ operator->()

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

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

References PtrDerefIter< IT >::i_.

◆ operator++()

template<class IT >
PtrDerefIter & operator++ ( )
inline

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

References PtrDerefIter< IT >::i_.

◆ isValid()

template<class IT >
bool isValid ( ) const
inline

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

References PtrDerefIter< IT >::i_.

Referenced by PtrDerefIter< IT >::empty(), and PtrDerefIter< IT >::operator bool().

+ Here is the caller graph for this function:

◆ empty()

template<class IT >
bool empty ( ) const
inline

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

References PtrDerefIter< IT >::isValid().

+ Here is the call graph for this function:

◆ getBase()

template<class IT >
IT const & getBase ( ) const
inline

access the wrapped implementation iterator

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

References PtrDerefIter< IT >::i_.

Referenced by PtrDerefIter< IT >::operator=(), and lib::operator==().

+ Here is the caller graph for this function:

Member Data Documentation

◆ i_

+ Collaboration diagram for PtrDerefIter< IT >:

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