File indexing completed on 2025-10-24 08:18:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <tuple>
0012 #include <utility>
0013
0014 namespace Acts {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 template <
0026 typename container_type,
0027 typename index_type = typename std::decay_t<container_type>::size_type,
0028 typename container_type_iter =
0029 decltype(std::begin(std::declval<container_type>())),
0030 typename = decltype(std::end(std::declval<container_type>()))>
0031 constexpr auto enumerate(container_type &&iterable) {
0032 struct iterator {
0033 index_type i;
0034 container_type_iter iter;
0035
0036 bool operator!=(const iterator &rhs) const { return iter != rhs.iter; }
0037
0038
0039 void operator++() {
0040 ++i;
0041 ++iter;
0042 }
0043
0044
0045 auto operator*() const { return std::tie(i, *iter); }
0046 };
0047 struct iterable_wrapper {
0048 container_type iterable;
0049 auto begin() { return iterator{0, std::begin(iterable)}; }
0050 auto end() { return iterator{0, std::end(iterable)}; }
0051 };
0052 return iterable_wrapper{std::forward<container_type>(iterable)};
0053 }
0054
0055 }