LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
enumerate.h
Go to the documentation of this file.
1 
10 #ifndef LARCOREALG_COREUTILS_ENUMERATE_H
11 #define LARCOREALG_COREUTILS_ENUMERATE_H
12 
13 // LArSoft libraries
16 
17 // C/C++ libraries
18 #include <cstddef> // std::size_t
19 #include <utility> // std::forward()
20 
21 namespace util {
22 
23  // -- BEGIN -- Enumerated iterations -----------------------------------------
26 
64  template <std::size_t Lead, typename... Iterables>
65  auto enumerate(Iterables&&... iterables)
66  {
67  return zip<Lead + 1>(infinite_counter(), std::forward<Iterables>(iterables)...);
68  }
69 
71  template <typename... Iterables>
72  auto enumerate(Iterables&&... iterables)
73  {
74  return enumerate<0U>(std::forward<Iterables>(iterables)...);
75  }
76 
78  // --- END -- Enumerated iterations ------------------------------------------
79 
80 } // namespace util
81 
82 #endif // LARCOREALG_COREUTILS_ENUMERATE_H
Definition of util::zip().
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
auto infinite_counter(T begin=T{})
Version of util::counter() starting at begin and never ending.
Definition: counter.h:302
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:65
Test of util::counter and support utilities.