|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // $Id$ 00002 // $Source$ 00003 // @HEADER 00004 // *********************************************************************** 00005 // 00006 // Sacado Package 00007 // Copyright (2006) Sandia Corporation 00008 // 00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00010 // the U.S. Government retains certain rights in this software. 00011 // 00012 // This library is free software; you can redistribute it and/or modify 00013 // it under the terms of the GNU Lesser General Public License as 00014 // published by the Free Software Foundation; either version 2.1 of the 00015 // License, or (at your option) any later version. 00016 // 00017 // This library is distributed in the hope that it will be useful, but 00018 // WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // Lesser General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with this library; if not, write to the Free Software 00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00025 // USA 00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps 00027 // (etphipp@sandia.gov). 00028 // 00029 // *********************************************************************** 00030 // @HEADER 00031 00032 #ifndef SACADO_MPL_VECTOR_HPP 00033 #define SACADO_MPL_VECTOR_HPP 00034 00035 #include "Sacado_mpl_none.hpp" 00036 #include "Sacado_mpl_size.hpp" 00037 #include "Sacado_mpl_begin.hpp" 00038 #include "Sacado_mpl_end.hpp" 00039 #include "Sacado_mpl_next.hpp" 00040 #include "Sacado_mpl_push_back.hpp" 00041 #include "Sacado_mpl_at.hpp" 00042 #include "Sacado_mpl_deref.hpp" 00043 00044 // Specializations needed for various mpl operations 00045 #include "Sacado_mpl_vector_size_spec.hpp" 00046 #include "Sacado_mpl_vector_at_spec.hpp" 00047 00048 namespace Sacado { 00049 00050 namespace mpl { 00051 00052 // vector tag for mpl operations 00053 struct vector_tag {}; 00054 00055 // vector 00056 template <class T0 = mpl::none, 00057 class T1 = mpl::none, 00058 class T2 = mpl::none, 00059 class T3 = mpl::none, 00060 class T4 = mpl::none, 00061 class T5 = mpl::none, 00062 class T6 = mpl::none, 00063 class T7 = mpl::none, 00064 class T8 = mpl::none, 00065 class T9 = mpl::none> 00066 struct vector : vector_size<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> { 00067 typedef vector_tag tag; 00068 typedef vector type; 00069 typedef T0 t0; 00070 typedef T1 t1; 00071 typedef T2 t2; 00072 typedef T3 t3; 00073 typedef T4 t4; 00074 typedef T5 t5; 00075 typedef T6 t6; 00076 typedef T7 t7; 00077 typedef T8 t8; 00078 typedef T9 t9; 00079 }; 00080 00081 // iterator 00082 template <class Vector, int Pos> 00083 struct vector_iterator { 00084 static const int value = Pos; 00085 }; 00086 00087 // size 00088 template <> 00089 struct size_impl<vector_tag> { 00090 template <class Vector> 00091 struct apply { 00092 static const int value = Vector::sz; 00093 }; 00094 }; 00095 00096 // begin 00097 template <> 00098 struct begin_impl<vector_tag> { 00099 template <class Vector> 00100 struct apply { 00101 typedef vector_iterator<Vector,0> type; 00102 }; 00103 }; 00104 00105 // end 00106 template <> 00107 struct end_impl<vector_tag> { 00108 template <class Vector> 00109 struct apply { 00110 typedef vector_iterator<Vector,Vector::sz> type; 00111 }; 00112 }; 00113 00114 // next 00115 template <class Vector, int Pos> 00116 struct next< vector_iterator<Vector,Pos> > { 00117 typedef vector_iterator<Vector,Pos+1> type; 00118 }; 00119 00120 00121 00122 // at 00123 template <int Pos> 00124 struct at_impl<vector_tag, Pos> { 00125 template <class Vector> 00126 struct apply : vector_at<Vector,Pos> {}; 00127 }; 00128 00129 // deref 00130 template <class Vector, int Pos> 00131 struct deref< vector_iterator<Vector,Pos> > : mpl::at<Vector,Pos> {}; 00132 00133 } 00134 00135 } 00136 00137 #include "Sacado_mpl_vector_push_back_spec.hpp" 00138 00139 namespace Sacado { 00140 namespace mpl { 00141 00142 // push_back 00143 template <> 00144 struct push_back_impl<vector_tag> { 00145 template <class Vector, class T> 00146 struct apply : vector_push_back<Vector, T, mpl::size<Vector>::value> {}; 00147 }; 00148 00149 } 00150 } 00151 00152 #endif
1.7.4