1 #ifndef VCSN_MISC_ZIP_HH
2 # define VCSN_MISC_ZIP_HH
4 # include <boost/iterator/iterator_facade.hpp>
12 template <
typename... Sequences>
19 template <std::size_t... I>
23 static constexpr
size_t size =
sizeof...(Sequences);
29 template <
typename Seq>
30 using seq_t =
typename std::remove_reference<Seq>::type;
34 = std::tuple<typename seq_t<Sequences>::value_type...>;
46 = std::tuple<typename seq_t<Sequences>::const_iterator...>;
50 = std::tuple<typename seq_t<Sequences>::iterator...>;
53 template <
typename ValueType,
54 typename IteratorsType>
56 :
public boost::iterator_facade<
57 zip_iterator<ValueType, IteratorsType>
59 , boost::forward_traversal_tag
70 template <
typename OtherValue,
typename OtherIterators>
110 template <std::size_t... I>
114 using swallow =
int[];
118 && (++std::get<I>(
is_) == std::get<I>(
ends_)
126 template <
typename OtherValue,
typename OtherIterators>
132 template <
typename OtherValue,
typename OtherIterators,
137 for (
auto n: {(std::get<I>(
is_) == std::get<I>(that.
is_))...})
144 template <std::size_t... I>
188 template <std::size_t... I>
195 template <std::size_t... I>
203 template <std::size_t... I>
210 template <std::size_t... I>
221 template <
typename... Sequences>
225 return {std::forward<Sequences>(seqs)...};
228 template <
typename... Sequences>
236 #endif // !VCSN_MISC_ZIP_HH
const_iterator cbegin() const
const_iterator cbegin_(seq< I...>) const
iterators_type is_
The current position.
const_iterator cend() const
zip_sequences(Sequences...sequences)
IteratorsType iterators_type
Underlying iterators.
void done_()
We have reached the end, move all the cursors to this end.
zip_iterator(const iterators_type &is, const iterators_type &ends)
iterator begin_(seq< I...>)
zip_sequences(const sequences_t &sequences)
std::tuple< typename seq_t< Sequences >::value_type...> value_type
The type of the members.
std::tuple< typename seq_t< Sequences >::iterator...> iterators_t
Tuple of iterators.
const_iterator cend_(seq< I...>) const
zip_sequences< Sequences...> zip(Sequences &&...seqs)
std::tuple< typename seq_t< Sequences >::const_iterator...> const_iterators_t
Tuple of const_iterators.
value_type dereference_(seq< I...>) const
Tuple of values.
zip_iterator & operator++()
Advance to next position.
friend class boost::iterator_core_access
std::tuple< Sequences...> sequences_t
Type of the tuple of all the maps.
const_iterator begin() const
std::istringstream is
The input stream: the specification to translate.
zip_sequences< Sequences...> zip_tuple(const std::tuple< Sequences...> &seqs)
const_iterator end() const
value_type operator*() const
typename std::remove_reference< Seq >::type seq_t
The type of the underlying sequences, without reference.
zip_iterator(zip_iterator< OtherValue, OtherIterators > const &that)
sequences_t sequences_
The sequences we iterate upon.
iterators_type ends_
The ends.
bool equal(const zip_iterator< OtherValue, OtherIterators > &that) const
bool next_()
Move to the next position.
bool equal_(const zip_iterator< OtherValue, OtherIterators > &that, seq< I...>) const
iterator end_(seq< I...>)
static constexpr size_t size
Number of sequences.