Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_Tuple.hpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_TUPLE_HPP
11#define TEUCHOS_TUPLE_HPP
12
13
14#include "Teuchos_ArrayView.hpp"
15
16
17namespace Teuchos {
18
19
34template<typename T, int N>
35class Tuple : public ArrayView<T> {
36public:
37
40 inline Tuple();
41
44 Tuple( const Tuple<T,N> &t );
45
49
50private:
51
52 T array_[N];
53
54};
55
56
61template<typename T> inline
63
64
69template<typename T> inline
70Tuple<T,2> tuple(const T& a, const T& b);
71
72
77template<typename T> inline
78Tuple<T,3> tuple(const T& a, const T& b, const T& c);
79
80
85template<typename T> inline
86Tuple<T,4> tuple(const T& a, const T& b, const T& c, const T& d);
87
88
93template<typename T> inline
94Tuple<T,5> tuple(const T& a, const T& b, const T& c, const T& d, const T& e);
95
96
101template<typename T> inline
102Tuple<T,6> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
103 const T& f);
104
105
110template<typename T> inline
111Tuple<T,7> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
112 const T& f, const T& g);
113
114
119template<typename T> inline
120Tuple<T,8> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
121 const T& f, const T& g, const T& h);
122
123
128template<typename T> inline
129Tuple<T,9> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
130 const T& f, const T& g, const T& h, const T& i);
131
132
137template<typename T> inline
138Tuple<T,10> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
139 const T& f, const T& g, const T& h, const T& i, const T& j);
140
141
146template<typename T> inline
147Tuple<T,11> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
148 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k);
149
150
155template<typename T> inline
156Tuple<T,12> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
157 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
158 const T& l);
159
160
165template<typename T> inline
166Tuple<T,13> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
167 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
168 const T& l, const T& m);
169
170
175template<typename T> inline
176Tuple<T,14> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
177 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
178 const T& l, const T& m, const T& n);
179
180
185template<typename T> inline
186Tuple<T,15> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
187 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
188 const T& l, const T& m, const T& n, const T& o);
189
190
191//
192// Implementations
193//
194
195
196template<typename T, int N> inline
198:ArrayView<T>() // To get rid of warnings!
199{
201}
202
203
204template<typename T, int N>
206:ArrayView<T>() // To get rid of warnings!
207{
208 for( int i = 0; i < N; ++i )
209 array_[i] = t[i];
210 // Above, this loop with static N should allow the compiler to unroll this
211 // entire loop!
213}
214
215
216template<typename T, int N>
218{
219 for( int i = 0; i < N; ++i )
220 array_[i] = t[i];
221 // Above, this loop with static N should allow the compiler to unroll this
222 // entire loop!
223 return *this;
224}
225
226
227} // end namespace Teuchos
228
229
230//
231// Nonmember function implementations
232//
233
234
235template<typename T> inline
237Teuchos::tuple(const T& a)
238{
239 Tuple<T,1> rtn;
240 rtn[0] = a;
241 return rtn;
242}
243
244
245template<typename T> inline
247Teuchos::tuple(const T& a, const T& b)
248{
249 Tuple<T,2> rtn;
250 rtn[0] = a;
251 rtn[1] = b;
252 return rtn;
253}
254
255
256template<typename T> inline
258Teuchos::tuple(const T& a, const T& b, const T& c)
259{
260 Tuple<T,3> rtn;
261 rtn[0] = a;
262 rtn[1] = b;
263 rtn[2] = c;
264 return rtn;
265}
266
267
268template<typename T> inline
270Teuchos::tuple(const T& a, const T& b, const T& c, const T& d)
271{
272 Tuple<T,4> rtn;;
273 rtn[0] = a;
274 rtn[1] = b;
275 rtn[2] = c;
276 rtn[3] = d;
277 return rtn;
278}
279
280
281template<typename T> inline
283Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e)
284{
285 Tuple<T,5> rtn;
286 rtn[0] = a;
287 rtn[1] = b;
288 rtn[2] = c;
289 rtn[3] = d;
290 rtn[4] = e;
291 return rtn;
292}
293
294
295template<typename T> inline
297Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
298 const T& f)
299{
300 Tuple<T,6> rtn;
301 rtn[0] = a;
302 rtn[1] = b;
303 rtn[2] = c;
304 rtn[3] = d;
305 rtn[4] = e;
306 rtn[5] = f;
307 return rtn;
308}
309
310
311template<typename T> inline
313Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
314 const T& f, const T& g)
315{
316 Tuple<T,7> rtn;
317 rtn[0] = a;
318 rtn[1] = b;
319 rtn[2] = c;
320 rtn[3] = d;
321 rtn[4] = e;
322 rtn[5] = f;
323 rtn[6] = g;
324 return rtn;
325}
326
327
328template<typename T> inline
330Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
331 const T& f, const T& g, const T& h)
332{
333 Tuple<T,8> rtn;
334 rtn[0] = a;
335 rtn[1] = b;
336 rtn[2] = c;
337 rtn[3] = d;
338 rtn[4] = e;
339 rtn[5] = f;
340 rtn[6] = g;
341 rtn[7] = h;
342 return rtn;
343}
344
345
346template<typename T> inline
348Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
349 const T& f, const T& g, const T& h, const T& i)
350{
351 Tuple<T,9> rtn;
352 rtn[0] = a;
353 rtn[1] = b;
354 rtn[2] = c;
355 rtn[3] = d;
356 rtn[4] = e;
357 rtn[5] = f;
358 rtn[6] = g;
359 rtn[7] = h;
360 rtn[8] = i;
361 return rtn;
362}
363
364
365template<typename T> inline
367Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
368 const T& f, const T& g, const T& h, const T& i, const T& j)
369{
370 Tuple<T,10> rtn;
371 rtn[0] = a;
372 rtn[1] = b;
373 rtn[2] = c;
374 rtn[3] = d;
375 rtn[4] = e;
376 rtn[5] = f;
377 rtn[6] = g;
378 rtn[7] = h;
379 rtn[8] = i;
380 rtn[9] = j;
381 return rtn;
382}
383
384
385template<typename T> inline
387Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
388 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k)
389{
390 Tuple<T,11> rtn;
391 rtn[0] = a;
392 rtn[1] = b;
393 rtn[2] = c;
394 rtn[3] = d;
395 rtn[4] = e;
396 rtn[5] = f;
397 rtn[6] = g;
398 rtn[7] = h;
399 rtn[8] = i;
400 rtn[9] = j;
401 rtn[10] = k;
402 return rtn;
403}
404
405template<typename T> inline
407Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
408 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
409 const T& l)
410{
411 Tuple<T,12> rtn;
412 rtn[0] = a;
413 rtn[1] = b;
414 rtn[2] = c;
415 rtn[3] = d;
416 rtn[4] = e;
417 rtn[5] = f;
418 rtn[6] = g;
419 rtn[7] = h;
420 rtn[8] = i;
421 rtn[9] = j;
422 rtn[10] = k;
423 rtn[11] = l;
424 return rtn;
425}
426
427template<typename T> inline
429Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
430 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
431 const T& l, const T& m)
432{
433 Tuple<T,13> rtn;
434 rtn[0] = a;
435 rtn[1] = b;
436 rtn[2] = c;
437 rtn[3] = d;
438 rtn[4] = e;
439 rtn[5] = f;
440 rtn[6] = g;
441 rtn[7] = h;
442 rtn[8] = i;
443 rtn[9] = j;
444 rtn[10] = k;
445 rtn[11] = l;
446 rtn[12] = m;
447 return rtn;
448}
449
450
451template<typename T> inline
453Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
454 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
455 const T& l, const T& m, const T& n)
456{
457 Tuple<T,14> rtn;
458 rtn[0] = a;
459 rtn[1] = b;
460 rtn[2] = c;
461 rtn[3] = d;
462 rtn[4] = e;
463 rtn[5] = f;
464 rtn[6] = g;
465 rtn[7] = h;
466 rtn[8] = i;
467 rtn[9] = j;
468 rtn[10] = k;
469 rtn[11] = l;
470 rtn[12] = m;
471 rtn[13] = n;
472 return rtn;
473}
474
475
476template<typename T> inline
478Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
479 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k,
480 const T& l, const T& m, const T& n, const T& o)
481{
482 Tuple<T,15> rtn;
483 rtn[0] = a;
484 rtn[1] = b;
485 rtn[2] = c;
486 rtn[3] = d;
487 rtn[4] = e;
488 rtn[5] = f;
489 rtn[6] = g;
490 rtn[7] = h;
491 rtn[8] = i;
492 rtn[9] = j;
493 rtn[10] = k;
494 rtn[11] = l;
495 rtn[12] = m;
496 rtn[13] = n;
497 rtn[14] = o;
498 return rtn;
499}
500
501
502#endif // TEUCHOS_TUPLE_HPP
Nonowning array view.
ArrayView< T > & operator=(const ArrayView< T > &array)
Shallow copy assignment operator.
Smart reference counting pointer class for automatic garbage collection.
Statically sized simple array (tuple) class.
Tuple()
Default construct raw storage.
Tuple< T, 15 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l, const T &m, const T &n, const T &o)
Create a Tuple<T,15>.
Tuple< T, N > & operator=(const Tuple< T, N > &t)
Copy constructor.
Tuple< T, 3 > tuple(const T &a, const T &b, const T &c)
Create a Tuple<T,3>.
Tuple< T, 2 > tuple(const T &a, const T &b)
Create a Tuple<T,2>.
Tuple< T, 5 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e)
Create a Tuple<T,5>.
Tuple< T, 13 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l, const T &m)
Create a Tuple<T,13>.
Tuple(const Tuple< T, N > &t)
Copy constructor.
Tuple< T, 4 > tuple(const T &a, const T &b, const T &c, const T &d)
Create a Tuple<T,4>.
Tuple< T, 8 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h)
Create a Tuple<T,8>.
Tuple< T, 12 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l)
Create a Tuple<T,12>.
Tuple< T, 6 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f)
Create a Tuple<T,6>.
Tuple< T, 10 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j)
Create a Tuple<T,10>.
Tuple< T, 1 > tuple(const T &a)
Create a Tuple<T,1>.
Tuple< T, 9 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i)
Create a Tuple<T,9>.
Tuple< T, 7 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g)
Create a Tuple<T,7>.
Tuple< T, 11 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k)
Create a Tuple<T,11>.
Tuple< T, 14 > tuple(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l, const T &m, const T &n)
Create a Tuple<T,14>.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...