Public Types | Public Member Functions | Protected Attributes | List of all members
proxy::details::IndexBasedIterator< Cont > Class Template Reference

Iterator to random access collection storing a current index. More...

#include <CollectionProxy.h>

Public Types

using container_t = Cont
 
using value_type = util::collection_value_t< container_t >
 
using const_iterator = IndexBasedIterator
 

Public Member Functions

 IndexBasedIterator ()=default
 Default constructor (required by iterator protocol): an unusable iterator. More...
 
 IndexBasedIterator (container_t const &cont, std::size_t index=0)
 Constructor: initializes from an iterator of the proxy main collection. More...
 
auto operator* () const -> decltype(auto)
 Returns the value pointed by this iterator. More...
 
const_iteratoroperator++ ()
 Returns the value pointed by this iterator. More...
 
bool operator!= (const_iterator const &other) const
 Returns whether the iterators point to the same element. More...
 

Protected Attributes

container_t const * fCont = nullptr
 Pointer to the original container. More...
 
std::size_t fIndex = std::numeric_limits<std::size_t>::max()
 Current index in the main collection. More...
 

Detailed Description

template<typename Cont>
class proxy::details::IndexBasedIterator< Cont >

Iterator to random access collection storing a current index.

Template Parameters
Conttype of random-access container to iterate

Cont is a type providing a public operator[](std::size_t) method.

Definition at line 33 of file CollectionProxy.h.

Member Typedef Documentation

template<typename Cont >
using proxy::details::IndexBasedIterator< Cont >::const_iterator = IndexBasedIterator

Definition at line 353 of file CollectionProxy.h.

template<typename Cont >
using proxy::details::IndexBasedIterator< Cont >::container_t = Cont

Definition at line 350 of file CollectionProxy.h.

Definition at line 352 of file CollectionProxy.h.

Constructor & Destructor Documentation

template<typename Cont >
proxy::details::IndexBasedIterator< Cont >::IndexBasedIterator ( )
default

Default constructor (required by iterator protocol): an unusable iterator.

template<typename Cont >
proxy::details::IndexBasedIterator< Cont >::IndexBasedIterator ( container_t const &  cont,
std::size_t  index = 0 
)
inline

Constructor: initializes from an iterator of the proxy main collection.

Definition at line 359 of file CollectionProxy.h.

360  : fCont(&cont), fIndex(index) {}
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.

Member Function Documentation

template<typename Cont >
bool proxy::details::IndexBasedIterator< Cont >::operator!= ( const_iterator const &  other) const
inline

Returns whether the iterators point to the same element.

Definition at line 370 of file CollectionProxy.h.

371  { return (other.fIndex != fIndex) || (other.fCont != fCont); }
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.
template<typename Cont >
auto proxy::details::IndexBasedIterator< Cont >::operator* ( ) const -> decltype(auto)
inline

Returns the value pointed by this iterator.

Definition at line 363 of file CollectionProxy.h.

364  { return fCont->operator[](fIndex); }
std::size_t fIndex
Current index in the main collection.
container_t const * fCont
Pointer to the original container.
template<typename Cont >
const_iterator& proxy::details::IndexBasedIterator< Cont >::operator++ ( )
inline

Returns the value pointed by this iterator.

Definition at line 367 of file CollectionProxy.h.

367 { ++fIndex; return *this; }
std::size_t fIndex
Current index in the main collection.

Member Data Documentation

template<typename Cont >
container_t const* proxy::details::IndexBasedIterator< Cont >::fCont = nullptr
protected

Pointer to the original container.

Definition at line 374 of file CollectionProxy.h.

template<typename Cont >
std::size_t proxy::details::IndexBasedIterator< Cont >::fIndex = std::numeric_limits<std::size_t>::max()
protected

Current index in the main collection.

Definition at line 377 of file CollectionProxy.h.


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