LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 98 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 110 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 114 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 113 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 111 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 103 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 112 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 127 of file zip.h.

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

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 208 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::fIterators.

Referenced by util::details::zip_iterator< Lead, Iters >::operator*().

209  {
210  // this complicate syntax appears to guarantee that the tuple types
211  // include a l-value reference when the dereference operator returns
212  // a l-value reference, and a r-value when the dereference operator
213  // returns one. Using `std::forward_as_reference()` instead,
214  // r-values are saved as r-value references. Using `std::tuple()`
215  // instead, all referenceness is stripped away, including l-value ones.
216  return std::tuple<decltype(*std::get<Indices>(fIterators))...>(
217  *std::get<Indices>(fIterators)...);
218  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:194
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 198 of file zip.h.

Referenced by util::details::zip_iterator< Lead, Iters >::increment_impl().

199  {}
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 141 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::fIterators.

142  {
143  return std::get<Index>(fIterators);
144  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:194
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 202 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::expandStatements(), and util::details::zip_iterator< Lead, Iters >::fIterators.

Referenced by util::details::zip_iterator< Lead, Iters >::operator++().

203  {
204  expandStatements(++std::get<Indices>(fIterators)...);
205  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:194
static void expandStatements(Args &...args)
Helper to trigger parameter pack expansion in expressions.
Definition: zip.h:198
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 178 of file zip.h.

179  {
180  return get<Lead>() != other.template get<OtherLead>();
181  }
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 137 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::dereference_impl().

137 { return dereference_impl(std::index_sequence_for<Iters...>()); }
auto dereference_impl(std::index_sequence< Indices... >) const
Definition: zip.h:208
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 154 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::increment_impl().

Referenced by util::details::zip_iterator< Lead, Iters >::operator++(), and util::details::zip_iterator< Lead >::operator++().

155  {
156  increment_impl(std::index_sequence_for<Iters...>());
157  return *this;
158  }
void increment_impl(std::index_sequence< Indices... >)
Definition: zip.h:202
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 162 of file zip.h.

References util::details::zip_iterator< Lead, Iters >::operator++().

163  {
164  this_iterator_t old(*this);
165  operator++();
166  return old;
167  }
this_iterator_t & operator++()
Increments all the iterators.
Definition: zip.h:154
zip_iterator< Lead, Iters... > this_iterator_t
Type of this object.
Definition: zip.h:103
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 185 of file zip.h.

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

Member Data Documentation

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

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