LArSoft  v10_04_05
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 (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 ( Iters &&...  iterators)
inline

Constructor: copies all iterator values.

Definition at line 124 of file zip.h.

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

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

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

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

206  {
207  // std::tie returns a tuple of references, which is what we want.
208  return std::tie(*std::get<Indices>(fIterators)...);
209  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:191
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 195 of file zip.h.

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

196  {}
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 138 of file zip.h.

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

139  {
140  return std::get<Index>(fIterators);
141  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:191
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 199 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++().

200  {
201  expandStatements(++std::get<Indices>(fIterators)...);
202  }
std::tuple< Iters... > fIterators
Tuple of all zipped iterators.
Definition: zip.h:191
static void expandStatements(Args &...args)
Helper to trigger parameter pack expansion in expressions.
Definition: zip.h:195
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 175 of file zip.h.

176  {
177  return get<Lead>() != other.template get<OtherLead>();
178  }
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 134 of file zip.h.

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

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

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

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

152  {
153  increment_impl(std::index_sequence_for<Iters...>());
154  return *this;
155  }
void increment_impl(std::index_sequence< Indices... >)
Definition: zip.h:199
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 159 of file zip.h.

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

160  {
161  this_iterator_t old(*this);
162  operator++();
163  return old;
164  }
this_iterator_t & operator++()
Increments all the iterators.
Definition: zip.h:151
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 182 of file zip.h.

183  {
184  return get<Lead>() == other.template get<OtherLead>();
185  }

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: