All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
util::details::zip_iterator< Lead, Iters > Class Template Reference

#include <zip.h>

Public Types

Data types
using difference_type = std::ptrdiff_t
 
using reference = std::tuple< typename std::iterator_traits< Iters >::reference...>
 
using value_type = std::remove_cv_t< reference >
 
using pointer = std::add_pointer_t< std::remove_reference_t< reference >>
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

Constructors
 zip_iterator ()=default
 Constructor: all iterators are default-constructed. More...
 
 zip_iterator (Iters &&...iterators)
 Constructor: copies all iterator values. More...
 
Access
auto operator* () const
 Returns a tuple with values from all dereferenced iterators. More...
 
template<std::size_t Index>
decltype(auto) get () const
 Returns the iterator at the specified Index. More...
 
Modification
this_iterator_toperator++ ()
 Increments all the iterators. More...
 
this_iterator_t operator++ (int)
 
Comparisons
template<std::size_t OtherLead, typename... OtherIter>
bool operator!= (zip_iterator< OtherLead, OtherIter...> const &other) const
 Comparison (based on the Lead iterator only). More...
 
template<std::size_t OtherLead, typename... OtherIter>
bool operator== (zip_iterator< OtherLead, OtherIter...> const &other) const
 Comparison (based on the Lead iterator only). More...
 

Private Types

using this_iterator_t = zip_iterator< Lead, Iters...>
 Type of this object. More...
 

Private Member Functions

template<std::size_t... Indices>
void increment_impl (std::index_sequence< Indices...>)
 
template<std::size_t... Indices>
auto dereference_impl (std::index_sequence< Indices...>) const
 

Static Private Member Functions

template<typename... Args>
static void expandStatements (Args &...args)
 Helper to trigger parameter pack expansion in expressions. More...
 

Private Attributes

std::tuple< Iters...> fIterators
 Tuple of all zipped iterators. More...
 

Detailed Description

template<std::size_t Lead, typename... Iters>
class util::details::zip_iterator< Lead, Iters >

Definition at line 101 of file zip.h.

Member Typedef Documentation

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::difference_type = std::ptrdiff_t

Definition at line 116 of file zip.h.

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::iterator_category = std::forward_iterator_tag

Definition at line 121 of file zip.h.

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::pointer = std::add_pointer_t<std::remove_reference_t<reference>>

Definition at line 120 of file zip.h.

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::reference = std::tuple<typename std::iterator_traits<Iters>::reference...>

Definition at line 118 of file zip.h.

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::this_iterator_t = zip_iterator<Lead, Iters...>
private

Type of this object.

Definition at line 107 of file zip.h.

template<std::size_t Lead, typename... Iters>
using util::details::zip_iterator< Lead, Iters >::value_type = std::remove_cv_t<reference>

Definition at line 119 of file zip.h.

Constructor & Destructor Documentation

template<std::size_t Lead, typename... Iters>
util::details::zip_iterator< Lead, Iters >::zip_iterator ( )
default

Constructor: all iterators are default-constructed.

template<std::size_t Lead, typename... Iters>
util::details::zip_iterator< Lead, Iters >::zip_iterator ( Iters &&...  iterators)
inline

Constructor: copies all iterator values.

Definition at line 135 of file zip.h.

136  : fIterators(std::forward<Iters>(iterators)...)
137  {}
std::tuple< Iters...> fIterators
Tuple of all zipped iterators.
Definition: zip.h:197

Member Function Documentation

template<std::size_t Lead, typename... Iters>
template<std::size_t... Indices>
auto util::details::zip_iterator< Lead, Iters >::dereference_impl ( std::index_sequence< Indices...>  ) const
inlineprivate

Definition at line 209 of file zip.h.

210  {
211  // this complicate syntax appears to guarantee that the tuple types
212  // include a l-value reference when the dereference operator returns
213  // a l-value reference, and a r-value when the dereference operator
214  // returns one. Using `std::forward_as_reference()` instead,
215  // r-values are saved as r-value references. Using `std::tuple()`
216  // instead, all referenceness is stripped away, including l-value ones.
217  return std::tuple<decltype(*std::get<Indices>(fIterators))...>
218  (*std::get<Indices>(fIterators)...);
219  }
std::tuple< Iters...> fIterators
Tuple of all zipped iterators.
Definition: zip.h:197
template<std::size_t Lead, typename... Iters>
template<typename... Args>
static void util::details::zip_iterator< Lead, Iters >::expandStatements ( Args &...  args)
inlinestaticprivate

Helper to trigger parameter pack expansion in expressions.

Definition at line 202 of file zip.h.

202 {}
template<std::size_t Lead, typename... Iters>
template<std::size_t Index>
decltype(auto) util::details::zip_iterator< Lead, Iters >::get ( ) const
inline

Returns the iterator at the specified Index.

Definition at line 153 of file zip.h.

153 { return std::get<Index>(fIterators); }
std::tuple< Iters...> fIterators
Tuple of all zipped iterators.
Definition: zip.h:197
template<std::size_t Lead, typename... Iters>
template<std::size_t... Indices>
void util::details::zip_iterator< Lead, Iters >::increment_impl ( std::index_sequence< Indices...>  )
inlineprivate

Definition at line 205 of file zip.h.

206  { expandStatements(++std::get<Indices>(fIterators)...); }
std::tuple< Iters...> fIterators
Tuple of all zipped iterators.
Definition: zip.h:197
static void expandStatements(Args &...args)
Helper to trigger parameter pack expansion in expressions.
Definition: zip.h:202
template<std::size_t Lead, typename... Iters>
template<std::size_t OtherLead, typename... OtherIter>
bool util::details::zip_iterator< Lead, Iters >::operator!= ( zip_iterator< OtherLead, OtherIter...> const &  other) const
inline

Comparison (based on the Lead iterator only).

Definition at line 182 of file zip.h.

183  { return get<Lead>() != other.template get<OtherLead>(); }
template<std::size_t Lead, typename... Iters>
auto util::details::zip_iterator< Lead, Iters >::operator* ( ) const
inline

Returns a tuple with values from all dereferenced iterators.

Definition at line 148 of file zip.h.

149  { return dereference_impl(std::index_sequence_for<Iters...>()); }
auto dereference_impl(std::index_sequence< Indices...>) const
Definition: zip.h:209
template<std::size_t Lead, typename... Iters>
this_iterator_t& util::details::zip_iterator< Lead, Iters >::operator++ ( )
inline

Increments all the iterators.

Definition at line 164 of file zip.h.

165  { increment_impl(std::index_sequence_for<Iters...>()); return *this; }
void increment_impl(std::index_sequence< Indices...>)
Definition: zip.h:205
template<std::size_t Lead, typename... Iters>
this_iterator_t util::details::zip_iterator< Lead, Iters >::operator++ ( int  )
inline

Returns a copy of the current iterators, then increments all of the iterators in this object.

Definition at line 169 of file zip.h.

170  { this_iterator_t old(*this); operator++(); return old; }
this_iterator_t & operator++()
Increments all the iterators.
Definition: zip.h:164
zip_iterator< Lead, Iters...> this_iterator_t
Type of this object.
Definition: zip.h:107
template<std::size_t Lead, typename... Iters>
template<std::size_t OtherLead, typename... OtherIter>
bool util::details::zip_iterator< Lead, Iters >::operator== ( zip_iterator< OtherLead, OtherIter...> const &  other) const
inline

Comparison (based on the Lead iterator only).

Definition at line 187 of file zip.h.

188  { return get<Lead>() == other.template get<OtherLead>(); }

Member Data Documentation

template<std::size_t Lead, typename... Iters>
std::tuple<Iters...> util::details::zip_iterator< Lead, Iters >::fIterators
private

Tuple of all zipped iterators.

Definition at line 197 of file zip.h.


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