Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_mpl_vector.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Sacado Package
5// Copyright (2006) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// This library is free software; you can redistribute it and/or modify
11// it under the terms of the GNU Lesser General Public License as
12// published by the Free Software Foundation; either version 2.1 of the
13// License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23// USA
24// Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25// (etphipp@sandia.gov).
26//
27// ***********************************************************************
28// @HEADER
29
30#ifndef SACADO_MPL_VECTOR_HPP
31#define SACADO_MPL_VECTOR_HPP
32
33#include "Sacado_ConfigDefs.h"
34#ifdef HAVE_SACADO_CXX11
35
36#include "Sacado_mpl_none.hpp"
37#include "Sacado_mpl_size.hpp"
38#include "Sacado_mpl_begin.hpp"
39#include "Sacado_mpl_end.hpp"
40#include "Sacado_mpl_next.hpp"
42#include "Sacado_mpl_at.hpp"
43#include "Sacado_mpl_deref.hpp"
44
45// Specializations needed for various mpl operations
47
48namespace Sacado {
49
50 namespace mpl {
51
52 // vector tag for mpl operations
53 struct vector_tag {};
54
55 // vector
56 template <typename... Args>
57 struct vector :
58 vector_size<Args...> {
59 typedef vector_tag tag;
60 typedef vector type;
61 };
62
63 // iterator
64 template <class Vector, int Pos>
65 struct vector_iterator {
66 static const int value = Pos;
67 };
68
69 // size
70 template <>
71 struct size_impl<vector_tag> {
72 template <class Vector>
73 struct apply {
74 static const int value = Vector::sz;
75 };
76 };
77
78 // begin
79 template <>
80 struct begin_impl<vector_tag> {
81 template <class Vector>
82 struct apply {
83 typedef vector_iterator<Vector,0> type;
84 };
85 };
86
87 // end
88 template <>
89 struct end_impl<vector_tag> {
90 template <class Vector>
91 struct apply {
92 typedef vector_iterator<Vector,Vector::sz> type;
93 };
94 };
95
96 // next
97 template <class Vector, int Pos>
98 struct next< vector_iterator<Vector,Pos> > {
99 typedef vector_iterator<Vector,Pos+1> type;
100 };
101
102 // deref
103 template <class Vector, int Pos>
104 struct deref< vector_iterator<Vector,Pos> > : mpl::at<Vector,Pos> {};
105
106 }
107
108}
109
112
113namespace Sacado {
114 namespace mpl {
115
116 // at
117 template <int Pos>
118 struct at_impl<vector_tag, Pos> {
119 template <class Vector>
120 struct apply : vector_at<Vector,Pos> {};
121 };
122
123 // push_back
124 template <>
125 struct push_back_impl<vector_tag> {
126 template <class Vector, class T>
127 struct apply : vector_push_back<Vector, T> {};
128 };
129
130 }
131}
132
133#endif
134
135#endif
int value