17 #ifndef AWALI_MISC_ZIP_MAPS_HH
18 # define AWALI_MISC_ZIP_MAPS_HH
21 # include <type_traits>
33 template <
typename Dereference =
as_tuple,
typename... Maps>
40 template <std::size_t... I>
58 = std::tuple<typename std::remove_reference<Maps>::type::const_iterator...>;
60 = std::tuple<typename std::remove_reference<Maps>::type::value_type...>;
64 = std::tuple<const typename std::remove_reference<Maps>::type::value_type&...>;
66 = std::tuple<std::pair<typename std::remove_reference<Maps>::type::const_iterator,
67 typename std::remove_reference<Maps>::type::const_iterator>...>;
70 =
typename std::remove_const<typename std::tuple_element<0, values_t>::type::first_type>::type;
73 = std::tuple<const typename std::remove_reference<Maps>::type::mapped_type&...>;
76 typename std::remove_reference<Maps>::type::const_iterator... is,
77 typename std::remove_reference<Maps>::type::const_iterator... ends)
138 return {dereference_first_(), dereference_second_(
indices_t{})};
155 if (std::get<0>(
is_) == std::get<0>(
ends_))
173 template <std::size_t... I>
176 using swallow =
int[];
177 (void) swallow{ (!
is_done_ && (k = align_<I>(k),
false))... };
183 template<std::
size_t I>
187 auto& first = std::get<I>(
is_);
191 while (first != std::get<I>(
ends_) && first->first < k)
193 if (first == std::get<I>(
ends_))
202 template <std::size_t... I>
203 bool not_equal_(
const iterator& that, seq<I...>)
const
205 for (
auto n: {(std::get<I>(
is_) != std::get<I>(that.is_))...})
212 key_t dereference_first_()
const
214 return std::get<0>(
is_)->first;
218 template <std::size_t... I>
219 mapped_t dereference_second_(seq<I...>)
const
227 template <std::size_t... I>
253 template <std::size_t... I>
254 iterator begin_(seq<I...>)
256 return iterator(*
this,
257 std::get<I>(maps_).
begin()...,
258 std::get<I>(maps_).
end()...);
261 template <std::size_t... I>
262 iterator end_(seq<I...>)
264 return iterator(*
this,
265 std::get<I>(maps_).
end()...,
266 std::get<I>(maps_).
end()...);
272 template <
typename Dereference = as_pair,
typename... Maps>
273 zipped_maps<Dereference, Maps...>
276 return {std::forward<Maps>(maps)...};
279 template <
typename Dereference = as_pair,
typename... Maps>
280 zipped_maps<Dereference, Maps...>
zip_sequences< Sequences... > zip(Sequences &&... seqs)
Definition: zip.hh:231
zipped_maps< Dereference, Maps... > zip_maps(Maps &&... maps)
Definition: zip_maps.hh:274
zipped_maps< Dereference, Maps... > zip_map_tuple(const std::tuple< Maps... > &maps)
Definition: zip_maps.hh:281
Definition: zip_maps.hh:31
Definition: zip_maps.hh:30
Main namespace of Awali.
Definition: ato.hh:22
Composite iterator.
Definition: zip_maps.hh:56
typename std::remove_const< typename std::tuple_element< 0, values_t >::type::first_type >::type key_t
Common key type.
Definition: zip_maps.hh:70
zipped_maps & zip_
The maps etc.
Definition: zip_maps.hh:87
iterator & operator++()
Advance to next position.
Definition: zip_maps.hh:97
std::pair< key_t, mapped_t > dereference_as_pair()
Return as <k1, <v1, v2...>>.
Definition: zip_maps.hh:136
auto operator*() -> decltype(this->dereference_(Dereference()))
Definition: zip_maps.hh:122
std::tuple< typename std::remove_reference< Maps >::type::value_type... > values_t
Definition: zip_maps.hh:60
std::tuple< const typename std::remove_reference< Maps >::type::value_type &... > references_t
Definition: zip_maps.hh:64
iterator(zipped_maps &zip, typename std::remove_reference< Maps >::type::const_iterator... is, typename std::remove_reference< Maps >::type::const_iterator... ends)
Definition: zip_maps.hh:75
std::tuple< const typename std::remove_reference< Maps >::type::mapped_type &... > mapped_t
Tuple of mapped types.
Definition: zip_maps.hh:73
bool is_done_
Whether we reached the end.
Definition: zip_maps.hh:94
values_t dereference_(as_tuple)
Definition: zip_maps.hh:117
iterators_t ends_
The genuine ends.
Definition: zip_maps.hh:92
std::pair< key_t, mapped_t > dereference_(as_pair)
Definition: zip_maps.hh:112
std::tuple< typename std::remove_reference< Maps >::type::const_iterator... > iterators_t
Definition: zip_maps.hh:58
iterators_t is_
The current position.
Definition: zip_maps.hh:90
std::tuple< std::pair< typename std::remove_reference< Maps >::type::const_iterator, typename std::remove_reference< Maps >::type::const_iterator >... > ranges_t
Definition: zip_maps.hh:67
references_t dereference_as_tuple()
Return as <<k1, v1>, <k1, v2>, ...>.
Definition: zip_maps.hh:130
bool operator!=(const iterator &that) const
Definition: zip_maps.hh:107
Definition: zip_maps.hh:35
std::tuple< Maps... > maps_t
Type of the tuple of all the maps.
Definition: zip_maps.hh:37
awali::internal::make_index_sequence< sizeof...(Maps)> indices_t
Index sequence for our maps.
Definition: zip_maps.hh:44
iterator end()
Definition: zip_maps.hh:247
zipped_maps(const maps_t &maps)
Definition: zip_maps.hh:50
zipped_maps(Maps... maps)
Definition: zip_maps.hh:46
iterator begin()
Definition: zip_maps.hh:241