SUNphi  1.0
IntListGetEl.hpp
Go to the documentation of this file.
1 #ifndef _INTLISTGETEL_HPP
2 #define _INTLISTGETEL_HPP
3 
4 /// \file IntListGetEl.hpp
5 ///
6 /// \brief Get an element of a list of integers
7 
8 namespace SUNphi
9 {
10  /// Returns I-th element of the integer list
11  ///
12  /// Internal implementation
13  template <int I, // Position of element to search
14  int Head, // First element
15  int...Tail> // Other components
16  constexpr int _getIntOfList()
17  {
18  if constexpr(I==0)
19  return Head;
20  else
21  {
22  static_assert(I<sizeof...(Tail)+1,"Asking for too large position");
23  return _getIntOfList<I-1,Tail...>();
24  }
25  }
26 
27  /// Returns I-th element of the sequence
28  template <int I, // Position of element to search
29  int...Ints> // Components
30  [[ maybe_unused ]]
31  constexpr int getIntOfList=
32  _getIntOfList<I,Ints...>();
33 }
34 #endif