Teuchos - Trilinos Tools Package Version of the Day
Teuchos_arrayArg.hpp
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 
00032 
00033 #include "Teuchos_TestForException.hpp"
00034 
00035 
00036 namespace Teuchos {
00037 
00038 
00164 template<int N, class T>
00165 class ArrayArg {
00166 public:
00168   ArrayArg( T array[] ) { std::copy( array, array+N, array_ ); }
00169 
00171   T* operator()() { return array_; }
00172 
00174   operator T* () { return array_; }
00175 
00176 private:
00177   T array_[N]; //  Can't be a const array!
00178 }; // class Array1DArg
00179 
00184 template<class T>
00185 inline TEUCHOS_DEPRECATED ArrayArg<1,T> arrayArg( T t1 )
00186 {
00187   T array[] = { t1 };
00188   return ArrayArg<1,T>(array);
00189 }
00190 
00195 template<class T>
00196 inline TEUCHOS_DEPRECATED ArrayArg<2,T> arrayArg( T t1, T t2 )
00197 {
00198   T array[] = { t1, t2 };
00199   return ArrayArg<2,T>(array);
00200 }
00201 
00206 template<class T>
00207 inline TEUCHOS_DEPRECATED ArrayArg<3,T> arrayArg( T t1, T t2, T t3 )
00208 {
00209   T array[] = { t1, t2, t3 };
00210   return ArrayArg<3,T>(array);
00211 }
00212 
00217 template<class T>
00218 inline TEUCHOS_DEPRECATED ArrayArg<4,T> arrayArg( T t1, T t2, T t3, T t4 )
00219 {
00220   T array[] = { t1, t2, t3, t4 };
00221   return ArrayArg<4,T>(array);
00222 }
00223 
00228 template<class T>
00229 inline TEUCHOS_DEPRECATED ArrayArg<5,T> arrayArg( T t1, T t2, T t3, T t4, T t5 )
00230 {
00231   T array[] = { t1, t2, t3, t4, t5 };
00232   return ArrayArg<5,T>(array);
00233 }
00234 
00239 template<class T>
00240 inline TEUCHOS_DEPRECATED ArrayArg<6,T> arrayArg( T t1, T t2, T t3, T t4, T t5, T t6 )
00241 {
00242   T array[] = { t1, t2, t3, t4, t5, t6 };
00243   return ArrayArg<6,T>(array);
00244 }
00245 
00246 } // namespace Teuchos
00247 
00248 #endif // TEUCHOS_ARRAY_ARG_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines