shards  Version of the Day
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups
Shards_IndexList.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Shards : Shared Discretization Tools
4 //
5 // Copyright 2008-2011 NTESS and the Shards contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef Shards_IndexList_hpp
11 #define Shards_IndexList_hpp
12 
13 namespace shards {
14 
27 template< int I0 = -1 , int I1 = -1 , int I2 = -1 , int I3 = -1 ,
28  int I4 = -1 , int I5 = -1 , int I6 = -1 , int I7 = -1 ,
29  int I8 = -1 , int I9 = -1 , int I10 = -1 , int I11 = -1 ,
30  int I12 = -1 , int I13 = -1 , int I14 = -1 , int I15 = -1 ,
31  int I16 = -1 , int I17 = -1 , int I18 = -1 , int I19 = -1 ,
32  int I20 = -1 , int I21 = -1 , int I22 = -1 , int I23 = -1 ,
33  int I24 = -1 , int I25 = -1 , int I26 = -1 , int I27 = -1 ,
34  int I28 = -1 , int I29 = -1 , int I30 = -1 , int I31 = -1 >
35 struct IndexList {};
36 
40 template< class List > struct IndexListLength {};
41 
45 template< class List , int J > struct IndexListAt {};
46 
50 template< class List , int J , bool OK = 0 <= J >
51 struct IndexListFind ;
52 
56 template< class List > struct IndexListInverse {};
57 
58 #ifndef DOXYGEN_COMPILE
59 
60 //----------------------------------------------------------------------
61 
62 template<>
63 struct IndexListLength< IndexList<> > { enum { value = 0 }; };
64 
65 template< int I0 , int I1 , int I2 , int I3 ,
66  int I4 , int I5 , int I6 , int I7 ,
67  int I8 , int I9 , int I10 , int I11 ,
68  int I12 , int I13 , int I14 , int I15 ,
69  int I16 , int I17 , int I18 , int I19 ,
70  int I20 , int I21 , int I22 , int I23 ,
71  int I24 , int I25 , int I26 , int I27 ,
72  int I28 , int I29 , int I30 , int I31 >
73 struct IndexListLength<
74  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
75  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
76  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
77  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
78 {
79 private:
80  typedef IndexList< I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
81  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
82  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
83  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 , -1 >
84  shift_type ;
85 
86 public:
87  enum { value = 1 + IndexListLength< shift_type >::value };
88 };
89 
90 //----------------------------------------------------------------------
91 
92 #define SHARDS_INDEX_LIST_AT_SPECIALIZATION( J , K ) \
93  template< int I0 , int I1 , int I2 , int I3 , \
94  int I4 , int I5 , int I6 , int I7 , \
95  int I8 , int I9 , int I10 , int I11 , \
96  int I12 , int I13 , int I14 , int I15 , \
97  int I16 , int I17 , int I18 , int I19 , \
98  int I20 , int I21 , int I22 , int I23 , \
99  int I24 , int I25 , int I26 , int I27 , \
100  int I28 , int I29 , int I30 , int I31 > \
101 struct IndexListAt< \
102  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 , \
103  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
104  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
105  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , J > \
106 { enum { value = K }; };
107 
108 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 0 , I0 )
109 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 1 , I1 )
110 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 2 , I2 )
111 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 3 , I3 )
112 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 4 , I4 )
113 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 5 , I5 )
114 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 6 , I6 )
115 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 7 , I7 )
116 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 8 , I8 )
117 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 9 , I9 )
118 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 10 , I10 )
119 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 11 , I11 )
120 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 12 , I12 )
121 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 13 , I13 )
122 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 14 , I14 )
123 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 15 , I15 )
124 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 16 , I16 )
125 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 17 , I17 )
126 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 18 , I18 )
127 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 19 , I19 )
128 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 20 , I20 )
129 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 21 , I21 )
130 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 22 , I22 )
131 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 23 , I23 )
132 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 24 , I24 )
133 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 25 , I25 )
134 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 26 , I26 )
135 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 27 , I27 )
136 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 28 , I28 )
137 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 29 , I29 )
138 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 30 , I30 )
139 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 31 , I31 )
140 
141 #undef SHARDS_INDEX_LIST_AT_SPECIALIZATION
142 
143 //----------------------------------------------------------------------
144 
145 template< class List , int J , bool OK >
146 struct IndexListFind { enum { value = -1 }; };
147 
148 #define SHARDS_INDEX_LIST_FIND_SPECIALIZATION( J , K ) \
149  template< int I0 , int I1 , int I2 , int I3 , \
150  int I4 , int I5 , int I6 , int I7 , \
151  int I8 , int I9 , int I10 , int I11 , \
152  int I12 , int I13 , int I14 , int I15 , \
153  int I16 , int I17 , int I18 , int I19 , \
154  int I20 , int I21 , int I22 , int I23 , \
155  int I24 , int I25 , int I26 , int I27 , \
156  int I28 , int I29 , int I30 , int I31 > \
157 struct IndexListFind< \
158  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 , \
159  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
160  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
161  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , K , true > \
162 { enum { value = J }; };
163 
164 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 0 , I0 )
165 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 1 , I1 )
166 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 2 , I2 )
167 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 3 , I3 )
168 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 4 , I4 )
169 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 5 , I5 )
170 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 6 , I6 )
171 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 7 , I7 )
172 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 8 , I8 )
173 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 9 , I9 )
174 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 10 , I10 )
175 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 11 , I11 )
176 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 12 , I12 )
177 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 13 , I13 )
178 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 14 , I14 )
179 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 15 , I15 )
180 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 16 , I16 )
181 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 17 , I17 )
182 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 18 , I18 )
183 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 19 , I19 )
184 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 20 , I20 )
185 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 21 , I21 )
186 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 22 , I22 )
187 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 23 , I23 )
188 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 24 , I24 )
189 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 25 , I25 )
190 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 26 , I26 )
191 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 27 , I27 )
192 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 28 , I28 )
193 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 29 , I29 )
194 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 30 , I30 )
195 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 31 , I31 )
196 
197 #undef SHARDS_INDEX_LIST_FIND_SPECIALIZATION
198 
199 //----------------------------------------------------------------------
200 
201 template< int I0 , int I1 , int I2 , int I3 ,
202  int I4 , int I5 , int I6 , int I7 ,
203  int I8 , int I9 , int I10 , int I11 ,
204  int I12 , int I13 , int I14 , int I15 ,
205  int I16 , int I17 , int I18 , int I19 ,
206  int I20 , int I21 , int I22 , int I23 ,
207  int I24 , int I25 , int I26 , int I27 ,
208  int I28 , int I29 , int I30 , int I31 >
209 struct IndexListInverse<
210  IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
211  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
212  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
213  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
214 {
215 private:
216  typedef IndexList< I0 , I1 , I2 , I3 , I4 , I5 , I6 , I7 ,
217  I8 , I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
218  I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
219  I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > list ;
220 
221  typedef IndexListInverse< list > SelfType ;
222 
223  enum { length = IndexListLength< list >::value };
224 
225  enum { J0 = IndexListFind< list , 0 , 0 < length >::value ,
226  J1 = IndexListFind< list , 1 , 1 < length >::value ,
227  J2 = IndexListFind< list , 2 , 2 < length >::value ,
228  J3 = IndexListFind< list , 3 , 3 < length >::value ,
229  J4 = IndexListFind< list , 4 , 4 < length >::value ,
230  J5 = IndexListFind< list , 5 , 5 < length >::value ,
231  J6 = IndexListFind< list , 6 , 6 < length >::value ,
232  J7 = IndexListFind< list , 7 , 7 < length >::value ,
233  J8 = IndexListFind< list , 8 , 8 < length >::value ,
234  J9 = IndexListFind< list , 9 , 9 < length >::value ,
235  J10 = IndexListFind< list , 10 , 10 < length >::value ,
236  J11 = IndexListFind< list , 11 , 11 < length >::value ,
237  J12 = IndexListFind< list , 12 , 12 < length >::value ,
238  J13 = IndexListFind< list , 13 , 13 < length >::value ,
239  J14 = IndexListFind< list , 14 , 14 < length >::value ,
240  J15 = IndexListFind< list , 15 , 15 < length >::value ,
241  J16 = IndexListFind< list , 16 , 16 < length >::value ,
242  J17 = IndexListFind< list , 17 , 17 < length >::value ,
243  J18 = IndexListFind< list , 18 , 18 < length >::value ,
244  J19 = IndexListFind< list , 19 , 19 < length >::value ,
245  J20 = IndexListFind< list , 20 , 20 < length >::value ,
246  J21 = IndexListFind< list , 21 , 21 < length >::value ,
247  J22 = IndexListFind< list , 22 , 22 < length >::value ,
248  J23 = IndexListFind< list , 23 , 23 < length >::value ,
249  J24 = IndexListFind< list , 24 , 24 < length >::value ,
250  J25 = IndexListFind< list , 25 , 25 < length >::value ,
251  J26 = IndexListFind< list , 26 , 26 < length >::value ,
252  J27 = IndexListFind< list , 27 , 27 < length >::value ,
253  J28 = IndexListFind< list , 28 , 28 < length >::value ,
254  J29 = IndexListFind< list , 29 , 29 < length >::value ,
255  J30 = IndexListFind< list , 30 , 30 < length >::value ,
256  J31 = IndexListFind< list , 31 , 31 < length >::value };
257 
258 public:
259 
260  typedef IndexList< SelfType::J0 , SelfType::J1 ,
261  SelfType::J2 , SelfType::J3 ,
262  SelfType::J4 , SelfType::J5 ,
263  SelfType::J6 , SelfType::J7 ,
264  SelfType::J8 , SelfType::J9 ,
265  SelfType::J10 , SelfType::J11 ,
266  SelfType::J12 , SelfType::J13 ,
267  SelfType::J14 , SelfType::J15 ,
268  SelfType::J16 , SelfType::J17 ,
269  SelfType::J18 , SelfType::J19 ,
270  SelfType::J20 , SelfType::J21 ,
271  SelfType::J22 , SelfType::J23 ,
272  SelfType::J24 , SelfType::J25 ,
273  SelfType::J26 , SelfType::J27 ,
274  SelfType::J28 , SelfType::J29 ,
275  SelfType::J30 , SelfType::J31 > type ;
276 };
277 
278 #endif /* DOXYGEN_COMPILE */
279 
282 } // namespace shards
283 
284 
285 #endif // Shards_IndexList_hpp
286 
Access member of compile-time list of indices. Defines enum { value = Jth member }; ...
Compile-time list of indices.
Length of list. Defines enum { value };