SUNphi  1.0
IntSeqCat.hpp
Go to the documentation of this file.
1 #ifndef _INTSEQCAT_HPP
2 #define _INTSEQCAT_HPP
3 
4 /// \file IntSeqCat.hpp
5 ///
6 /// \brief Cat one or more integer sequences and lists
7 
8 #include <ints/IntSeq.hpp>
9 
10 namespace SUNphi
11 {
12  /////////////////////////////////////////////////////////////////////////
13 
14  /// Internal implementation of sequence-of-integer catter.
15  ///
16  /// Dummy prototype to be specialized with actual case.
17  template <class...T>
18  struct _IntSeqCat;
19 
20  /// Internal implementation of sequence-of-integer catter.
21  ///
22  /// Takes into account catting a single instance of IntSeq, useful
23  /// also to terminate the catter. Called also when the general case
24  /// runs out of argument.
25  ///
26  /// Example:
27  /// \code
28  /// using Seq=IntSeq<1,2,3,4>;
29  /// IntSeqCat<Seq>::type test; //IntSeq<1,2,3,4>
30  /// \endcode
31  template <int...Ints>
32  struct _IntSeqCat<IntSeq<Ints...>>
33  {
34  typedef IntSeq<Ints...> type; ///< Internally mapped type
35  };
36 
37  /// Internal implementation of sequence-of-integer catter.
38  ///
39  /// Takes into account catting nothing.
40  ///
41  /// Example:
42  /// \code
43  /// IntSeqCat<>::type test; //IntSeq<>
44  /// \endcode
45  template <>
46  struct _IntSeqCat<>
47  {
48  typedef IntSeq<> type; ///< Internally mapped type
49  };
50 
51  /// Internal implementation of sequence-of-integer catter.
52  ///
53  /// Takes into account the general case of an arbitary number of
54  /// IntSeq, instantiating recursively the binary cat types.
55  ///
56  /// Example:
57  /// \code
58  /// using Seq=IntSeq<1,2,3,4>;
59  /// IntSeqCat<Seq,Seq>::type test; //IntSeq<1,2,3,4,1,2,3,4>
60  /// \endcode
61  template <int...Ints1,
62  int...Ints2,
63  class...T>
64  struct _IntSeqCat<IntSeq<Ints1...>,IntSeq<Ints2...>,T...>
65  {
66  /// Binary cat \c Ints1..., \c Ints2..., separated for clarity
67  using Nested=
68  IntSeq<Ints1...,Ints2...>;
69 
70  /// Result of catting the whole list \c Ints1, \c Ints2,...
71  typedef typename _IntSeqCat<Nested,T...>::type type;
72  };
73 
74  /// Sequence-of-integer catter.
75  ///
76  /// Wraps the implementation to avoid writing "type"
77  template <class...T>
78  using IntSeqCat=
79  typename _IntSeqCat<T...>::type;
80 }
81 
82 #endif
IntSeq type
Internally mapped type.
Definition: IntSeqCat.hpp:48
_IntSeqCat< Nested, T... >::type type
Result of catting the whole list Ints1, Ints2,...
Definition: IntSeqCat.hpp:71
IntSeq< Ints... > type
Internally mapped type.
Definition: IntSeqCat.hpp:34
static constexpr int element()
Get the I element of the sequence.
Definition: IntSeq.hpp:95