5 #include <boost/iterator/iterator_facade.hpp> 15 template <
typename... Sequences>
24 template <std::size_t... I>
28 static constexpr
size_t size =
sizeof...(Sequences);
34 template <
typename Seq>
35 using seq_t = std::remove_reference_t<Seq>;
39 = std::tuple<typename seq_t<Sequences>::value_type...>;
51 = std::tuple<typename seq_t<Sequences>::const_iterator...>;
55 = std::tuple<typename seq_t<Sequences>::iterator...>;
58 template <
typename ValueType,
59 typename IteratorsType>
61 :
public boost::iterator_facade<
62 cross_iterator<ValueType, IteratorsType>
64 , boost::forward_traversal_tag
86 template <
typename OtherValue,
typename OtherIterators>
124 template <std::size_t... I>
127 for (
auto n: {(std::get<I>(
begins_) == std::get<I>(ends_))...})
151 template <std::size_t... I>
155 using swallow =
int[];
159 && std::get<size-1-I>(
is_) != std::get<size-1-I>(ends_)
160 && ++std::get<size-1-I>(
is_) != std::get<size-1-I>(ends_))
174 template <std::size_t... I>
177 using swallow =
int[];
181 && ((std::get<I>(
is_) = std::get<I>(begins_)),
true))...
185 template <std::size_t... I>
188 for (
auto n: {(std::get<I>(
is_) == std::get<I>(that.
is_))...})
195 template <std::size_t... I>
259 template <std::size_t... I>
269 template <std::size_t... I>
277 template <std::size_t... I>
286 template <std::size_t... I>
301 template <
typename... Sequences>
305 return {std::forward<Sequences>(seqs)...};
308 template <
typename... Sequences>
IteratorsType iterators_type
Underlying iterators.
int increment_()
Move to the next position.
iterator end_(seq< I... >)
std::tuple< typename seq_t< Sequences >::iterator... > iterators_t
Tuple of iterators.
bool skip_first_
Whether to skip the initial element.
cross_iterator(const iterators_type &is, const iterators_type &begins, const iterators_type &ends)
bool empty() const
Whether the sequence is empty.
bool empty() const
Whether some of the range is empty.
sequences_t sequences_
The sequences we iterate upon.
void done_()
We have reached the end, move all the cursors to this end.
static constexpr size_t size
Number of sequences.
std::tuple< typename seq_t< Sequences >::const_iterator... > const_iterators_t
Tuple of const_iterators.
std::remove_reference_t< Seq > seq_t
The type of the underlying sequences, without reference.
cross_sequences(sequences_t sequences)
cross_sequences< Sequences... > cross_tuple(const std::tuple< Sequences... > &seqs)
auto tuple(const Auts &... as)
Build the (accessible part of the) tuple.
const_iterator cbegin() const
bool equal_(const cross_iterator &that, seq< I... >) const
iterators_type ends_
The ends.
iterators_type begins_
The begins.
const_iterator cend() const
bool equal(const cross_iterator &that) const
iterator begin_(seq< I... >)
void increment()
Advance to next position.
Build the static sequence of size_t [0, N[.
Provide a range that allows to iterate over the cross product of the provided ranges.
cross_sequences< Sequences... > cross(Sequences &&... seqs)
cross_iterator(cross_iterator< OtherValue, OtherIterators > const &that)
const_iterator cbegin_(seq< I... >) const
value_type dereference() const
iterators_type is_
The current position.
cross_sequences(Sequences... sequences)
std::tuple< typename seq_t< Sequences >::value_type... > value_type
The type of the members.
std::tuple< Sequences... > sequences_t
Type of the tuple of all the maps.
self_t & skip_first(bool s=true)
Whether to skip the first element.
int increment_(seq< I... >)
void reset_up_to_(size_t n, seq< I... >)
const_iterator begin() const
void reset_up_to_(int n)
Move beginning of ranges to their end, and align.
const_iterator end() const
const_iterator cend_(seq< I... >) const
value_type dereference_(seq< I... >) const
Tuple of values.
bool empty_(seq< I... >) const
cross_iterator(const iterators_type &is, const iterators_type &ends)
friend class boost::iterator_core_access