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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef TEUCHOS_ARRAY_ARG_HPP
00043 #define TEUCHOS_ARRAY_ARG_HPP
00044 
00045 
00046 #include "Teuchos_Assert.hpp"
00047 
00048 
00049 namespace Teuchos {
00050 
00051 
00177 template<int N, class T>
00178 class ArrayArg {
00179 public:
00181   ArrayArg( T array[] ) { std::copy( array, array+N, array_ ); }
00182 
00184   T* operator()() { return array_; }
00185 
00187   operator T* () { return array_; }
00188 
00189 private:
00190   T array_[N]; //  Can't be a const array!
00191 }; // class Array1DArg
00192 
00197 template<class T>
00198 inline TEUCHOS_DEPRECATED ArrayArg<1,T> arrayArg( T t1 )
00199 {
00200   T array[] = { t1 };
00201   return ArrayArg<1,T>(array);
00202 }
00203 
00208 template<class T>
00209 inline TEUCHOS_DEPRECATED ArrayArg<2,T> arrayArg( T t1, T t2 )
00210 {
00211   T array[] = { t1, t2 };
00212   return ArrayArg<2,T>(array);
00213 }
00214 
00219 template<class T>
00220 inline TEUCHOS_DEPRECATED ArrayArg<3,T> arrayArg( T t1, T t2, T t3 )
00221 {
00222   T array[] = { t1, t2, t3 };
00223   return ArrayArg<3,T>(array);
00224 }
00225 
00230 template<class T>
00231 inline TEUCHOS_DEPRECATED ArrayArg<4,T> arrayArg( T t1, T t2, T t3, T t4 )
00232 {
00233   T array[] = { t1, t2, t3, t4 };
00234   return ArrayArg<4,T>(array);
00235 }
00236 
00241 template<class T>
00242 inline TEUCHOS_DEPRECATED ArrayArg<5,T> arrayArg( T t1, T t2, T t3, T t4, T t5 )
00243 {
00244   T array[] = { t1, t2, t3, t4, t5 };
00245   return ArrayArg<5,T>(array);
00246 }
00247 
00252 template<class T>
00253 inline TEUCHOS_DEPRECATED ArrayArg<6,T> arrayArg( T t1, T t2, T t3, T t4, T t5, T t6 )
00254 {
00255   T array[] = { t1, t2, t3, t4, t5, t6 };
00256   return ArrayArg<6,T>(array);
00257 }
00258 
00259 } // namespace Teuchos
00260 
00261 #endif // TEUCHOS_ARRAY_ARG_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines