1 #ifndef VCSN_MISC_ZIP_MAPS_HH
2 # define VCSN_MISC_ZIP_MAPS_HH
5 # include <type_traits>
16 template <
typename Dereference =
as_tuple,
typename... Maps>
23 template <std::size_t... I>
41 = std::tuple<typename std::remove_reference<Maps>::type::const_iterator...>;
43 = std::tuple<typename std::remove_reference<Maps>::type::value_type...>;
47 = std::tuple<const typename std::remove_reference<Maps>::type::value_type&...>;
49 = std::tuple<std::pair<typename std::remove_reference<Maps>::type::const_iterator,
50 typename std::remove_reference<Maps>::type::const_iterator>...>;
53 =
typename std::remove_const<typename std::tuple_element<0, values_t>::type::first_type>::type;
56 = std::tuple<const typename std::remove_reference<Maps>::type::mapped_type&...>;
59 typename std::remove_reference<Maps>::type::const_iterator...
is,
60 typename std::remove_reference<Maps>::type::const_iterator... ends)
138 if (std::get<0>(
is_) == std::get<0>(
ends_))
156 template <std::size_t... I>
159 using swallow =
int[];
160 (void) swallow{ (!
is_done_ && (k = align_<I>(k),
false))... };
166 template<std::
size_t I>
170 auto& first = std::get<I>(
is_);
174 while (first != std::get<I>(
ends_) && first->first < k)
176 if (first == std::get<I>(
ends_))
185 template <std::size_t... I>
188 for (
auto n: {(std::get<I>(
is_) != std::get<I>(that.
is_))...})
197 return std::get<0>(
is_)->first;
201 template <std::size_t... I>
210 template <std::size_t... I>
236 template <std::size_t... I>
244 template <std::size_t... I>
255 template <
typename Dereference =
as_pair,
typename... Maps>
259 return {std::forward<Maps>(maps)...};
262 template <
typename Dereference =
as_pair,
typename... Maps>
270 #endif // !VCSN_MISC_ZIP_MAPS_HH
std::tuple< std::pair< typename std::remove_reference< Maps >::type::const_iterator, typename std::remove_reference< Maps >::type::const_iterator >...> ranges_t
iterators_t is_
The current position.
key_t dereference_first_() const
The common key.
iterator & operator++()
Advance to next position.
iterator begin_(seq< I...>)
void align_()
Align all iterators on the first common key.
zipped_maps(const maps_t &maps)
auto operator*() -> decltype(this->dereference_(Dereference()))
std::tuple< const typename std::remove_reference< Maps >::type::mapped_type &...> mapped_t
Tuple of mapped types.
std::pair< key_t, mapped_t > dereference_as_pair()
Return as >.
std::tuple< typename std::remove_reference< Maps >::type::value_type...> values_t
bool is_done_
Whether we reached the end.
bool not_equal_(const iterator &that, seq< I...>) const
zip_sequences< Sequences...> zip(Sequences &&...seqs)
typename std::remove_const< typename std::tuple_element< 0, values_t >::type::first_type >::type key_t
Common key type.
zipped_maps< Dereference, Maps...> zip_map_tuple(const std::tuple< Maps...> &maps)
mapped_t dereference_second_(seq< I...>) const
The associated tuple of values.
std::tuple< typename std::remove_reference< Maps >::type::const_iterator...> iterators_t
zipped_maps & zip_
The maps etc.
references_t dereference_as_tuple()
Return as <, , ...>.
std::istringstream is
The input stream: the specification to translate.
iterator(zipped_maps &zip, typename std::remove_reference< Maps >::type::const_iterator...is, typename std::remove_reference< Maps >::type::const_iterator...ends)
iterators_t ends_
The genuine ends.
std::tuple< Maps...> maps_t
Type of the tuple of all the maps.
std::pair< key_t, mapped_t > dereference_(as_pair)
key_t align_(key_t k, seq< I...>)
Try to align all the ranges to support key k.
key_t align_(key_t k)
Given the current candidate key, try to find the proper range for I.
references_t dereference_(seq< I...>) const
Tuple of pairs.
void done_()
We have reached the end, move all the cursors to this end.
values_t dereference_(as_tuple)
zipped_maps< Dereference, Maps...> zip_maps(Maps &&...maps)
bool operator!=(const iterator &that) const
std::tuple< const typename std::remove_reference< Maps >::type::value_type &...> references_t
iterator end_(seq< I...>)