5 #include <boost/iterator/iterator_facade.hpp>
15 template <
typename... Sequences>
22 template <std::size_t... I>
26 static constexpr
size_t size =
sizeof...(Sequences);
32 template <
typename Seq>
33 using seq_t = std::remove_reference_t<Seq>;
37 = std::tuple<typename seq_t<Sequences>::value_type...>;
49 = std::tuple<typename seq_t<Sequences>::const_iterator...>;
53 = std::tuple<typename seq_t<Sequences>::iterator...>;
56 template <
typename ValueType,
57 typename IteratorsType>
59 :
public boost::iterator_facade<
60 cross_iterator<ValueType, IteratorsType>
62 , boost::forward_traversal_tag
84 template <
typename OtherValue,
typename OtherIterators>
122 template <std::size_t... I>
125 for (
auto n: {(std::get<I>(
begins_) == std::get<I>(ends_))...})
149 template <std::size_t... I>
153 using swallow =
int[];
157 && std::get<size-1-I>(
is_) != std::get<size-1-I>(ends_)
158 && ++std::get<size-1-I>(
is_) != std::get<size-1-I>(ends_))
172 template <std::size_t... I>
175 using swallow =
int[];
179 && ((std::get<I>(
is_) = std::get<I>(begins_)),
true))...
183 template <std::size_t... I>
186 for (
auto n: {(std::get<I>(
is_) == std::get<I>(that.
is_))...})
193 template <std::size_t... I>
246 template <std::size_t... I>
256 template <std::size_t... I>
264 template <std::size_t... I>
273 template <std::size_t... I>
285 template <
typename... Sequences>
289 return {std::forward<Sequences>(seqs)...};
292 template <
typename... Sequences>
cross_iterator(const iterators_type &is, const iterators_type &ends)
std::tuple< Sequences... > sequences_t
Type of the tuple of all the maps.
bool empty() const
Whether the sequence is empty.
iterators_type ends_
The ends.
iterator begin_(seq< I... >)
const_iterator cend_(seq< I... >) const
std::tuple< typename seq_t< Sequences >::const_iterator... > const_iterators_t
Tuple of const_iterators.
const_iterator cend() const
sequences_t sequences_
The sequences we iterate upon.
bool empty_(seq< I... >) const
cross_iterator(const iterators_type &is, const iterators_type &begins, const iterators_type &ends)
void reset_up_to_(size_t n, seq< I... >)
int increment_(seq< I... >)
static constexpr size_t size
Number of sequences.
const_iterator cbegin() const
bool equal(const cross_iterator &that) const
iterators_type is_
The current position.
bool equal_(const cross_iterator &that, seq< I... >) const
void done_()
We have reached the end, move all the cursors to this end.
cross_iterator(cross_iterator< OtherValue, OtherIterators > const &that)
std::tuple< typename seq_t< Sequences >::iterator... > iterators_t
Tuple of iterators.
std::remove_reference_t< Seq > seq_t
The type of the underlying sequences, without reference.
cross_sequences(sequences_t sequences)
iterators_type begins_
The begins.
friend class boost::iterator_core_access
iterator end_(seq< I... >)
const_iterator cbegin_(seq< I... >) const
void increment()
Advance to next position.
auto tuple(const Auts &...as)
Build the (accessible part of the) tuple.
cross_sequences< Sequences... > cross_tuple(const std::tuple< Sequences... > &seqs)
Provide a range that allows to iterate over the cross product of the provided ranges.
const_iterator end() const
IteratorsType iterators_type
Underlying iterators.
cross_sequences< Sequences... > cross(Sequences &&...seqs)
std::tuple< typename seq_t< Sequences >::value_type... > value_type
The type of the members.
cross_sequences(Sequences...sequences)
bool empty() const
Whether some of the range is empty.
int increment_()
Move to the next position.
const_iterator begin() const
value_type dereference_(seq< I... >) const
Tuple of values.
void reset_up_to_(int n)
Move beginning of ranges to their end, and align.
value_type dereference() const