10 #ifndef LARCOREALG_COREUTILS_ZIP_H
11 #define LARCOREALG_COREUTILS_ZIP_H
19 #include <type_traits>
74 template <std::size_t Lead,
typename... Iterables>
75 auto zip(Iterables&&... iterables);
79 template <
typename... Iterables>
80 auto zip(Iterables&&... iterables)
81 {
return zip<0U>(std::forward<Iterables>(iterables)...); }
97 namespace util::details {
100 template <std::size_t Lead,
typename... Iters>
103 static_assert(Lead <
sizeof...(Iters),
104 "The index (Lead) of the leading iterator is invalid.");
118 = std::tuple<typename std::iterator_traits<Iters>::reference...>;
120 using pointer = std::add_pointer_t<std::remove_reference_t<reference>>;
152 template <std::
size_t Index>
165 {
increment_impl(std::index_sequence_for<Iters...>());
return *
this; }
181 template <std::size_t OtherLead,
typename... OtherIter>
183 {
return get<Lead>() != other.template get<OtherLead>(); }
186 template <std::size_t OtherLead,
typename... OtherIter>
188 {
return get<Lead>() == other.template get<OtherLead>(); }
201 template <
typename... Args>
204 template <std::size_t... Indices>
208 template <std::size_t... Indices>
217 return std::tuple<decltype(*std::get<Indices>(
fIterators))...>
227 template <std::
size_t Lead>
239 using pointer = std::add_pointer_t<std::remove_reference_t<reference>>;
254 template <std::size_t OtherLead,
typename... OtherIter>
259 template <std::size_t OtherLead,
typename... OtherIter>
267 template <std::size_t Lead,
typename... Iterables>
272 {
begin(iterables)... };
278 template <std::size_t Lead,
typename... Iterables>
283 {
end(iterables)... };
294 template <std::size_t Lead ,
typename... Iterables>
298 details::make_zip_begin_iterator<Lead>(iterables...),
299 details::make_zip_end_iterator<Lead>(iterables...)
308 #endif // LARCOREALG_COREUTILS_ZIP_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
zip_iterator()=default
Constructor: all iterators are default-constructed.
An object with a begin and end iterator.
bool operator!=(zip_iterator< OtherLead, OtherIter...> const &other) const
Comparison (based on the Lead iterator only).
std::tuple< Iters...> fIterators
Tuple of all zipped iterators.
std::add_pointer_t< std::remove_reference_t< reference >> pointer
auto make_zip_begin_iterator(Iterables &&...iterables)
decltype(auto) get() const
Returns the iterator at the specified Index.
void increment_impl(std::index_sequence< Indices...>)
std::ptrdiff_t difference_type
Simple class with a begin and an end.
std::remove_cv_t< reference > value_type
std::tuple< typename std::iterator_traits< Iters >::reference...> reference
std::add_pointer_t< std::remove_reference_t< reference >> pointer
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
static void expandStatements(Args &...args)
Helper to trigger parameter pack expansion in expressions.
auto dereference_impl(std::index_sequence< Indices...>) const
std::forward_iterator_tag iterator_category
auto end(FixedBins< T, C > const &) noexcept
auto operator*() const
Returns a tuple with values from all dereferenced iterators.
auto begin(FixedBins< T, C > const &) noexcept
std::ptrdiff_t difference_type
std::remove_cv_t< reference > value_type
this_iterator_t & operator++()
Increments all the iterators.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
bool operator==(zip_iterator< OtherLead, OtherIter...> const &other) const
Comparison (based on the Lead iterator only).
zip_iterator(Iters &&...iterators)
Constructor: copies all iterator values.
auto make_zip_end_iterator(Iterables &&...iterables)
std::forward_iterator_tag iterator_category