1 #ifndef VCSN_MISC_CROSS_HH
2 # define VCSN_MISC_CROSS_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 cross_iterator<ValueType, IteratorsType>
59 , boost::forward_traversal_tag
71 template <
typename OtherValue,
typename OtherIterators>
124 template <std::size_t... I>
128 using swallow =
int[];
133 && std::next(std::get<size-1-I>(
is_)) != std::get<
size-1-I>(
ends_))
147 template <std::size_t... I>
150 using swallow =
int[];
154 && ((std::get<I>(
is_) = std::get<I>(
begins_)),
true))...
158 template <std::size_t... I>
161 for (
auto n: {(std::get<I>(
is_) != std::get<I>(that.
is_))...})
168 template <std::size_t... I>
214 template <std::size_t... I>
221 template <std::size_t... I>
228 template <std::size_t... I>
235 template <std::size_t... I>
246 template <
typename... Sequences>
250 return {std::forward<Sequences>(seqs)...};
253 template <
typename... Sequences>
261 #endif // !VCSN_MISC_CROSS_HH
cross_iterator(const iterators_type &is, const iterators_type &ends)
iterator end_(seq< I...>)
cross_sequences(const sequences_t &sequences)
std::tuple< typename seq_t< Sequences >::value_type...> value_type
The type of the members.
static constexpr size_t size
Number of sequences.
void reset_up_to_(size_t n, seq< I...>)
std::tuple< typename seq_t< Sequences >::const_iterator...> const_iterators_t
Tuple of const_iterators.
const_iterator cend() const
value_type dereference_(seq< I...>) const
Tuple of values.
typename std::remove_reference< Seq >::type seq_t
The type of the underlying sequences, without reference.
iterators_type is_
The current position.
std::tuple< Sequences...> sequences_t
Type of the tuple of all the maps.
sequences_t sequences_
The sequences we iterate upon.
value_type operator*() const
iterator begin_(seq< I...>)
int next_()
Move to the next position.
cross_sequences< Sequences...> cross_tuple(const std::tuple< Sequences...> &seqs)
cross_iterator(cross_iterator< OtherValue, OtherIterators > const &that)
bool not_equal_(const cross_iterator &that, seq< I...>) const
const_iterator cbegin() const
cross_sequences(Sequences...sequences)
void done_()
We have reached the end, move all the cursors to this end.
const_iterator cbegin_(seq< I...>) const
const_iterator cend_(seq< I...>) const
std::istringstream is
The input stream: the specification to translate.
const_iterator end() const
cross_sequences< Sequences...> cross(Sequences &&...seqs)
void reset_up_to_(int n)
Move beginning of ranges to their end, and align.
friend class boost::iterator_core_access
bool operator!=(const cross_iterator &that) const
const_iterator begin() const
IteratorsType iterators_type
Underlying iterators.
std::tuple< typename seq_t< Sequences >::iterator...> iterators_t
Tuple of iterators.
iterators_type ends_
The ends.
iterators_type begins_
The begins.
cross_iterator & operator++()
Advance to next position.