Teuchos - Trilinos Tools Package
Version of the Day
core
src
Teuchos_Tuple.hpp
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Teuchos: Common Tools Package
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef TEUCHOS_TUPLE_HPP
43
#define TEUCHOS_TUPLE_HPP
44
45
46
#include "Teuchos_ArrayView.hpp"
47
48
49
namespace
Teuchos
{
50
51
66
template
<
typename
T,
int
N>
67
class
Tuple
:
public
ArrayView
<T> {
68
public
:
69
72
inline
Tuple
();
73
76
Tuple
(
const
Tuple<T,N>
&t );
77
80
Tuple<T,N>
&
operator=
(
const
Tuple<T,N>
&t );
81
82
private
:
83
84
T array_[N];
85
86
};
87
88
93
template
<
typename
T>
inline
94
Tuple<T,1>
tuple(
const
T& a);
95
96
101
template
<
typename
T>
inline
102
Tuple<T,2>
tuple(
const
T& a,
const
T& b);
103
104
109
template
<
typename
T>
inline
110
Tuple<T,3>
tuple(
const
T& a,
const
T& b,
const
T& c);
111
112
117
template
<
typename
T>
inline
118
Tuple<T,4>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d);
119
120
125
template
<
typename
T>
inline
126
Tuple<T,5>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e);
127
128
133
template
<
typename
T>
inline
134
Tuple<T,6>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
135
const
T& f);
136
137
142
template
<
typename
T>
inline
143
Tuple<T,7>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
144
const
T& f,
const
T& g);
145
146
151
template
<
typename
T>
inline
152
Tuple<T,8>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
153
const
T& f,
const
T& g,
const
T& h);
154
155
160
template
<
typename
T>
inline
161
Tuple<T,9>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
162
const
T& f,
const
T& g,
const
T& h,
const
T& i);
163
164
169
template
<
typename
T>
inline
170
Tuple<T,10>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
171
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j);
172
173
178
template
<
typename
T>
inline
179
Tuple<T,11>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
180
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k);
181
182
187
template
<
typename
T>
inline
188
Tuple<T,12>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
189
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
190
const
T& l);
191
192
197
template
<
typename
T>
inline
198
Tuple<T,13>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
199
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
200
const
T& l,
const
T& m);
201
202
207
template
<
typename
T>
inline
208
Tuple<T,14>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
209
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
210
const
T& l,
const
T& m,
const
T& n);
211
212
217
template
<
typename
T>
inline
218
Tuple<T,15>
tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
219
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
220
const
T& l,
const
T& m,
const
T& n,
const
T& o);
221
222
223
//
224
// Implementations
225
//
226
227
228
template
<
typename
T,
int
N>
inline
229
Tuple<T,N>::Tuple
()
230
:
ArrayView
<T>()
// To get rid of warnings!
231
{
232
ArrayView<T>::operator=
(
ArrayView<T>
(&array_[0],N));
233
}
234
235
236
template
<
typename
T,
int
N>
237
Tuple<T,N>::Tuple
(
const
Tuple<T,N>
&t )
238
:
ArrayView
<T>()
// To get rid of warnings!
239
{
240
for
(
int
i = 0; i < N; ++i )
241
array_[i] = t[i];
242
// Above, this loop with static N should allow the compiler to unroll this
243
// entire loop!
244
ArrayView<T>::operator=
(
ArrayView<T>
(&array_[0],N));
245
}
246
247
248
template
<
typename
T,
int
N>
249
Tuple<T,N>
&
Tuple<T,N>::operator=
(
const
Tuple<T,N>
&t )
250
{
251
for
(
int
i = 0; i < N; ++i )
252
array_[i] = t[i];
253
// Above, this loop with static N should allow the compiler to unroll this
254
// entire loop!
255
return
*
this
;
256
}
257
258
259
}
// end namespace Teuchos
260
261
262
//
263
// Nonmember function implementations
264
//
265
266
267
template
<
typename
T>
inline
268
Teuchos::Tuple<T,1>
269
Teuchos::tuple(
const
T& a)
270
{
271
Tuple<T,1> rtn;
272
rtn[0] = a;
273
return
rtn;
274
}
275
276
277
template
<
typename
T>
inline
278
Teuchos::Tuple<T,2>
279
Teuchos::tuple(
const
T& a,
const
T& b)
280
{
281
Tuple<T,2> rtn;
282
rtn[0] = a;
283
rtn[1] = b;
284
return
rtn;
285
}
286
287
288
template
<
typename
T>
inline
289
Teuchos::Tuple<T,3>
290
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c)
291
{
292
Tuple<T,3> rtn;
293
rtn[0] = a;
294
rtn[1] = b;
295
rtn[2] = c;
296
return
rtn;
297
}
298
299
300
template
<
typename
T>
inline
301
Teuchos::Tuple<T,4>
302
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d)
303
{
304
Tuple<T,4> rtn;;
305
rtn[0] = a;
306
rtn[1] = b;
307
rtn[2] = c;
308
rtn[3] = d;
309
return
rtn;
310
}
311
312
313
template
<
typename
T>
inline
314
Teuchos::Tuple<T,5>
315
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e)
316
{
317
Tuple<T,5> rtn;
318
rtn[0] = a;
319
rtn[1] = b;
320
rtn[2] = c;
321
rtn[3] = d;
322
rtn[4] = e;
323
return
rtn;
324
}
325
326
327
template
<
typename
T>
inline
328
Teuchos::Tuple<T,6>
329
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
330
const
T& f)
331
{
332
Tuple<T,6> rtn;
333
rtn[0] = a;
334
rtn[1] = b;
335
rtn[2] = c;
336
rtn[3] = d;
337
rtn[4] = e;
338
rtn[5] = f;
339
return
rtn;
340
}
341
342
343
template
<
typename
T>
inline
344
Teuchos::Tuple<T,7>
345
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
346
const
T& f,
const
T& g)
347
{
348
Tuple<T,7> rtn;
349
rtn[0] = a;
350
rtn[1] = b;
351
rtn[2] = c;
352
rtn[3] = d;
353
rtn[4] = e;
354
rtn[5] = f;
355
rtn[6] = g;
356
return
rtn;
357
}
358
359
360
template
<
typename
T>
inline
361
Teuchos::Tuple<T,8>
362
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
363
const
T& f,
const
T& g,
const
T& h)
364
{
365
Tuple<T,8> rtn;
366
rtn[0] = a;
367
rtn[1] = b;
368
rtn[2] = c;
369
rtn[3] = d;
370
rtn[4] = e;
371
rtn[5] = f;
372
rtn[6] = g;
373
rtn[7] = h;
374
return
rtn;
375
}
376
377
378
template
<
typename
T>
inline
379
Teuchos::Tuple<T,9>
380
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
381
const
T& f,
const
T& g,
const
T& h,
const
T& i)
382
{
383
Tuple<T,9> rtn;
384
rtn[0] = a;
385
rtn[1] = b;
386
rtn[2] = c;
387
rtn[3] = d;
388
rtn[4] = e;
389
rtn[5] = f;
390
rtn[6] = g;
391
rtn[7] = h;
392
rtn[8] = i;
393
return
rtn;
394
}
395
396
397
template
<
typename
T>
inline
398
Teuchos::Tuple<T,10>
399
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
400
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j)
401
{
402
Tuple<T,10> rtn;
403
rtn[0] = a;
404
rtn[1] = b;
405
rtn[2] = c;
406
rtn[3] = d;
407
rtn[4] = e;
408
rtn[5] = f;
409
rtn[6] = g;
410
rtn[7] = h;
411
rtn[8] = i;
412
rtn[9] = j;
413
return
rtn;
414
}
415
416
417
template
<
typename
T>
inline
418
Teuchos::Tuple<T,11>
419
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
420
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k)
421
{
422
Tuple<T,11> rtn;
423
rtn[0] = a;
424
rtn[1] = b;
425
rtn[2] = c;
426
rtn[3] = d;
427
rtn[4] = e;
428
rtn[5] = f;
429
rtn[6] = g;
430
rtn[7] = h;
431
rtn[8] = i;
432
rtn[9] = j;
433
rtn[10] = k;
434
return
rtn;
435
}
436
437
template
<
typename
T>
inline
438
Teuchos::Tuple<T,12>
439
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
440
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
441
const
T& l)
442
{
443
Tuple<T,12> rtn;
444
rtn[0] = a;
445
rtn[1] = b;
446
rtn[2] = c;
447
rtn[3] = d;
448
rtn[4] = e;
449
rtn[5] = f;
450
rtn[6] = g;
451
rtn[7] = h;
452
rtn[8] = i;
453
rtn[9] = j;
454
rtn[10] = k;
455
rtn[11] = l;
456
return
rtn;
457
}
458
459
template
<
typename
T>
inline
460
Teuchos::Tuple<T,13>
461
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
462
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
463
const
T& l,
const
T& m)
464
{
465
Tuple<T,13> rtn;
466
rtn[0] = a;
467
rtn[1] = b;
468
rtn[2] = c;
469
rtn[3] = d;
470
rtn[4] = e;
471
rtn[5] = f;
472
rtn[6] = g;
473
rtn[7] = h;
474
rtn[8] = i;
475
rtn[9] = j;
476
rtn[10] = k;
477
rtn[11] = l;
478
rtn[12] = m;
479
return
rtn;
480
}
481
482
483
template
<
typename
T>
inline
484
Teuchos::Tuple<T,14>
485
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
486
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
487
const
T& l,
const
T& m,
const
T& n)
488
{
489
Tuple<T,14> rtn;
490
rtn[0] = a;
491
rtn[1] = b;
492
rtn[2] = c;
493
rtn[3] = d;
494
rtn[4] = e;
495
rtn[5] = f;
496
rtn[6] = g;
497
rtn[7] = h;
498
rtn[8] = i;
499
rtn[9] = j;
500
rtn[10] = k;
501
rtn[11] = l;
502
rtn[12] = m;
503
rtn[13] = n;
504
return
rtn;
505
}
506
507
508
template
<
typename
T>
inline
509
Teuchos::Tuple<T,15>
510
Teuchos::tuple(
const
T& a,
const
T& b,
const
T& c,
const
T& d,
const
T& e,
511
const
T& f,
const
T& g,
const
T& h,
const
T& i,
const
T& j,
const
T& k,
512
const
T& l,
const
T& m,
const
T& n,
const
T& o)
513
{
514
Tuple<T,15> rtn;
515
rtn[0] = a;
516
rtn[1] = b;
517
rtn[2] = c;
518
rtn[3] = d;
519
rtn[4] = e;
520
rtn[5] = f;
521
rtn[6] = g;
522
rtn[7] = h;
523
rtn[8] = i;
524
rtn[9] = j;
525
rtn[10] = k;
526
rtn[11] = l;
527
rtn[12] = m;
528
rtn[13] = n;
529
rtn[14] = o;
530
return
rtn;
531
}
532
533
534
#endif // TEUCHOS_TUPLE_HPP
Teuchos::Tuple::Tuple
Tuple()
Default construct raw storage.
Definition:
Teuchos_Tuple.hpp:229
Teuchos::Tuple
Statically sized simple array (tuple) class.
Definition:
Teuchos_Tuple.hpp:67
Teuchos::ArrayView
Nonowning array view.
Definition:
Teuchos_ArrayViewDecl.hpp:123
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Teuchos::Tuple::operator=
Tuple< T, N > & operator=(const Tuple< T, N > &t)
Copy constructor.
Definition:
Teuchos_Tuple.hpp:249
Generated by
1.8.16