17 #ifndef AWALI_MISC_ZIP_HH
18 # define AWALI_MISC_ZIP_HH
27 template <
typename... Sequences>
34 template <std::size_t... I>
38 static constexpr
size_t size =
sizeof...(Sequences);
44 template <
typename Seq>
45 using seq_t =
typename std::remove_reference<Seq>::type;
49 = std::tuple<typename seq_t<Sequences>::value_type...>;
52 : sequences_(sequences)
56 : sequences_(sequences...)
61 = std::tuple<typename seq_t<Sequences>::const_iterator...>;
65 = std::tuple<typename seq_t<Sequences>::iterator...>;
68 template <
typename ValueType,
69 typename IteratorsType>
80 template <
typename OtherValue,
typename OtherIterators>
118 template <std::size_t... I>
119 bool next_(seq<I...>)
122 using swallow =
int[];
126 && (++std::get<I>(
is_) == std::get<I>(
ends_)
134 template <
typename OtherValue,
typename OtherIterators>
135 bool equal(
const zip_iterator<OtherValue, OtherIterators>& that)
const
140 template <
typename OtherValue,
typename OtherIterators,
142 bool equal_(
const zip_iterator<OtherValue, OtherIterators>& that,
145 for (
auto n: {(std::get<I>(
is_) == std::get<I>(that.is_))...})
152 template <std::size_t... I>
196 template <std::size_t... I>
203 template <std::size_t... I>
211 template <std::size_t... I>
214 return {
iterators_t{std::get<I>(sequences_).begin()...},
218 template <std::size_t... I>
221 return {
iterators_t{std::get<I>(sequences_).end()...},
229 template <
typename... Sequences>
230 zip_sequences<Sequences...>
233 return {std::forward<Sequences>(seqs)...};
236 template <
typename... Sequences>
237 zip_sequences<Sequences...>
zip_sequences< Sequences... > zip(Sequences &&... seqs)
Definition: zip.hh:231
zip_sequences< Sequences... > zip_tuple(const std::tuple< Sequences... > &seqs)
Definition: zip.hh:238
Main namespace of Awali.
Definition: ato.hh:22
Composite iterator.
Definition: zip.hh:71
iterators_type is_
The current position.
Definition: zip.hh:87
zip_iterator & operator++()
Advance to next position.
Definition: zip.hh:92
zip_iterator(zip_iterator< OtherValue, OtherIterators > const &that)
Definition: zip.hh:81
zip_iterator(const iterators_type &is, const iterators_type &ends)
Definition: zip.hh:75
value_type operator*() const
Definition: zip.hh:99
iterators_type ends_
The ends.
Definition: zip.hh:89
IteratorsType iterators_type
Underlying iterators.
Definition: zip.hh:73
std::tuple< typename seq_t< Sequences >::const_iterator... > const_iterators_t
Tuple of const_iterators.
Definition: zip.hh:61
zip_sequences(const sequences_t &sequences)
Definition: zip.hh:51
const_iterator begin() const
Definition: zip.hh:175
const_iterator cend() const
Definition: zip.hh:170
iterator begin()
Definition: zip.hh:185
std::tuple< typename seq_t< Sequences >::value_type... > value_type
The type of the members.
Definition: zip.hh:49
const_iterator end() const
Definition: zip.hh:180
zip_sequences(Sequences... sequences)
Definition: zip.hh:55
iterator end()
Definition: zip.hh:190
typename std::remove_reference< Seq >::type seq_t
The type of the underlying sequences, without reference.
Definition: zip.hh:45
awali::internal::make_index_sequence< sizeof...(Sequences)> indices_t
Index sequence for our sequences.
Definition: zip.hh:41
const_iterator cbegin() const
Definition: zip.hh:165
std::tuple< Sequences... > sequences_t
Type of the tuple of all the maps.
Definition: zip.hh:31
std::tuple< typename seq_t< Sequences >::iterator... > iterators_t
Tuple of iterators.
Definition: zip.hh:65
zip_iterator< const value_type, const_iterators_t > const_iterator
Const iterator.
Definition: zip.hh:163
zip_iterator< value_type, iterators_t > iterator
Mutable iterator.
Definition: zip.hh:160
static constexpr size_t size
Number of sequences.
Definition: zip.hh:38