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 // /////////////////////////////////////////////////////////////
00030 // Teuchos_arrayArg.hpp
00031 
00032 #ifndef TEUCHOS_ARRAY_ARG_HPP
00033 #define TEUCHOS_ARRAY_ARG_HPP
00034 
00039 #include "Teuchos_TestForException.hpp"
00040 
00041 namespace Teuchos {
00042 
00162 
00163 
00167 template<int N, class T>
00168 class ArrayArg {
00169 public:
00171   ArrayArg( T array[] ) { std::copy( array, array+N, array_ ); }
00172 
00174   T* operator()() { return array_; }
00175 
00177   operator T* () { return array_; }
00178 
00179 private:
00180   T array_[N]; //  Can't be a const array!
00181 }; // class Array1DArg
00182 
00184 
00188 template<class T>
00189 inline ArrayArg<1,T> arrayArg( T t1 )
00190 {
00191   T array[] = { t1 };
00192   return ArrayArg<1,T>(array);
00193 }
00194 
00196 
00200 template<class T>
00201 inline ArrayArg<2,T> arrayArg( T t1, T t2 )
00202 {
00203   T array[] = { t1, t2 };
00204   return ArrayArg<2,T>(array);
00205 }
00206 
00208 
00212 template<class T>
00213 inline ArrayArg<3,T> arrayArg( T t1, T t2, T t3 )
00214 {
00215   T array[] = { t1, t2, t3 };
00216   return ArrayArg<3,T>(array);
00217 }
00218 
00220 
00224 template<class T>
00225 inline ArrayArg<4,T> arrayArg( T t1, T t2, T t3, T t4 )
00226 {
00227   T array[] = { t1, t2, t3, t4 };
00228   return ArrayArg<4,T>(array);
00229 }
00230 
00232 
00236 template<class T>
00237 inline ArrayArg<5,T> arrayArg( T t1, T t2, T t3, T t4, T t5 )
00238 {
00239   T array[] = { t1, t2, t3, t4, t5 };
00240   return ArrayArg<5,T>(array);
00241 }
00242 
00244 
00248 template<class T>
00249 inline ArrayArg<6,T> arrayArg( T t1, T t2, T t3, T t4, T t5, T t6 )
00250 {
00251   T array[] = { t1, t2, t3, t4, t5, t6 };
00252   return ArrayArg<6,T>(array);
00253 }
00254 
00255 } // namespace Teuchos
00256 
00257 #endif // TEUCHOS_ARRAY_ARG_HPP

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