Teuchos_arrayArg.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef TEUCHOS_ARRAY_ARG_HPP
00030 #define TEUCHOS_ARRAY_ARG_HPP
00031 
00036 #include "Teuchos_TestForException.hpp"
00037 
00038 namespace Teuchos {
00039 
00163 template<int N, class T>
00164 class ArrayArg {
00165 public:
00167   ArrayArg( T array[] ) { std::copy( array, array+N, array_ ); }
00168 
00170   T* operator()() { return array_; }
00171 
00173   operator T* () { return array_; }
00174 
00175 private:
00176   T array_[N]; //  Can't be a const array!
00177 }; // class Array1DArg
00178 
00183 template<class T>
00184 inline ArrayArg<1,T> arrayArg( T t1 )
00185 {
00186   T array[] = { t1 };
00187   return ArrayArg<1,T>(array);
00188 }
00189 
00194 template<class T>
00195 inline ArrayArg<2,T> arrayArg( T t1, T t2 )
00196 {
00197   T array[] = { t1, t2 };
00198   return ArrayArg<2,T>(array);
00199 }
00200 
00205 template<class T>
00206 inline ArrayArg<3,T> arrayArg( T t1, T t2, T t3 )
00207 {
00208   T array[] = { t1, t2, t3 };
00209   return ArrayArg<3,T>(array);
00210 }
00211 
00216 template<class T>
00217 inline ArrayArg<4,T> arrayArg( T t1, T t2, T t3, T t4 )
00218 {
00219   T array[] = { t1, t2, t3, t4 };
00220   return ArrayArg<4,T>(array);
00221 }
00222 
00227 template<class T>
00228 inline ArrayArg<5,T> arrayArg( T t1, T t2, T t3, T t4, T t5 )
00229 {
00230   T array[] = { t1, t2, t3, t4, t5 };
00231   return ArrayArg<5,T>(array);
00232 }
00233 
00238 template<class T>
00239 inline ArrayArg<6,T> arrayArg( T t1, T t2, T t3, T t4, T t5, T t6 )
00240 {
00241   T array[] = { t1, t2, t3, t4, t5, t6 };
00242   return ArrayArg<6,T>(array);
00243 }
00244 
00245 } // namespace Teuchos
00246 
00247 #endif // TEUCHOS_ARRAY_ARG_HPP

Generated on Thu Sep 18 12:39:09 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1