Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_Tuple.hpp
Go to the documentation of this file.
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 
17 namespace Teuchos {
18 
19 
34 template<typename T, int N>
35 class Tuple : public ArrayView<T> {
36 public:
37 
40  inline Tuple();
41 
44  Tuple( const Tuple<T,N> &t );
45 
48  Tuple<T,N>& operator=( const Tuple<T,N> &t );
49 
50 private:
51 
52  T array_[N];
53 
54 };
55 
56 
61 template<typename T> inline
62 Tuple<T,1> tuple(const T& a);
63 
64 
69 template<typename T> inline
70 Tuple<T,2> tuple(const T& a, const T& b);
71 
72 
77 template<typename T> inline
78 Tuple<T,3> tuple(const T& a, const T& b, const T& c);
79 
80 
85 template<typename T> inline
86 Tuple<T,4> tuple(const T& a, const T& b, const T& c, const T& d);
87 
88 
93 template<typename T> inline
94 Tuple<T,5> tuple(const T& a, const T& b, const T& c, const T& d, const T& e);
95 
96 
101 template<typename T> inline
102 Tuple<T,6> tuple(const T& a, const T& b, const T& c, const T& d, const T& e,
103  const T& f);
104 
105 
110 template<typename T> inline
111 Tuple<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 
119 template<typename T> inline
120 Tuple<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 
128 template<typename T> inline
129 Tuple<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 
137 template<typename T> inline
138 Tuple<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 
146 template<typename T> inline
147 Tuple<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 
155 template<typename T> inline
156 Tuple<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 
165 template<typename T> inline
166 Tuple<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 
175 template<typename T> inline
176 Tuple<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 
185 template<typename T> inline
186 Tuple<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 
196 template<typename T, int N> inline
198 :ArrayView<T>() // To get rid of warnings!
199 {
201 }
202 
203 
204 template<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 
216 template<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 
235 template<typename T> inline
237 Teuchos::tuple(const T& a)
238 {
239  Tuple<T,1> rtn;
240  rtn[0] = a;
241  return rtn;
242 }
243 
244 
245 template<typename T> inline
247 Teuchos::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 
256 template<typename T> inline
258 Teuchos::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 
268 template<typename T> inline
270 Teuchos::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 
281 template<typename T> inline
283 Teuchos::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 
295 template<typename T> inline
297 Teuchos::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 
311 template<typename T> inline
313 Teuchos::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 
328 template<typename T> inline
330 Teuchos::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 
346 template<typename T> inline
348 Teuchos::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 
365 template<typename T> inline
367 Teuchos::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 
385 template<typename T> inline
387 Teuchos::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 
405 template<typename T> inline
407 Teuchos::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 
427 template<typename T> inline
429 Teuchos::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 
451 template<typename T> inline
453 Teuchos::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 
476 template<typename T> inline
478 Teuchos::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
Tuple< T, N > & operator=(const Tuple< T, N > &t)
Copy constructor.
Statically sized simple array (tuple) class.
Nonowning array view.
Tuple()
Default construct raw storage.
ArrayView< T > & operator=(const ArrayView< T > &array)
Shallow copy assignment operator.