File indexing completed on 2025-01-18 09:11:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <tuple>
0012
0013 namespace Acts {
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 template <typename... R>
0025 auto zip(R &&...r) {
0026 struct It {
0027 std::tuple<decltype(r.begin())...> iterators;
0028 static_assert(std::tuple_size_v<decltype(iterators)> > 0);
0029
0030 using reference = std::tuple<decltype(*r.begin())...>;
0031
0032 auto operator++() {
0033 std::apply([](auto &...args) { (++args, ...); }, iterators);
0034 return *this;
0035 }
0036
0037 auto operator!=(const It &other) const {
0038 return std::get<0>(iterators) != std::get<0>(other.iterators);
0039 }
0040
0041 reference operator*() {
0042 return std::apply([](auto &...args) { return reference{*args...}; },
0043 iterators);
0044 }
0045 };
0046
0047 struct Zip {
0048 It b, e;
0049
0050 auto begin() { return b; }
0051 auto end() { return e; }
0052 };
0053
0054 auto begin = std::make_tuple(r.begin()...);
0055 auto end = std::make_tuple(r.end()...);
0056 return Zip{It{begin}, It{end}};
0057 }
0058
0059 }