Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_arrayArg.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TEUCHOS_ARRAY_ARG_HPP
43 #define TEUCHOS_ARRAY_ARG_HPP
44 
45 
46 #include "Teuchos_Assert.hpp"
47 
48 
49 namespace Teuchos {
50 
51 
177 template<int N, class T>
178 class ArrayArg {
179 public:
181  ArrayArg( T array[] ) { std::copy( array, array+N, array_ ); }
182 
184  T* operator()() { return array_; }
185 
187  operator T* () { return array_; }
188 
189 private:
190  T array_[N]; // Can't be a const array!
191 }; // class Array1DArg
192 
197 template<class T>
198 inline TEUCHOS_DEPRECATED ArrayArg<1,T> arrayArg( T t1 )
199 {
200  T array[] = { t1 };
201  return ArrayArg<1,T>(array);
202 }
203 
208 template<class T>
209 inline TEUCHOS_DEPRECATED ArrayArg<2,T> arrayArg( T t1, T t2 )
210 {
211  T array[] = { t1, t2 };
212  return ArrayArg<2,T>(array);
213 }
214 
219 template<class T>
220 inline TEUCHOS_DEPRECATED ArrayArg<3,T> arrayArg( T t1, T t2, T t3 )
221 {
222  T array[] = { t1, t2, t3 };
223  return ArrayArg<3,T>(array);
224 }
225 
230 template<class T>
231 inline TEUCHOS_DEPRECATED ArrayArg<4,T> arrayArg( T t1, T t2, T t3, T t4 )
232 {
233  T array[] = { t1, t2, t3, t4 };
234  return ArrayArg<4,T>(array);
235 }
236 
241 template<class T>
242 inline TEUCHOS_DEPRECATED ArrayArg<5,T> arrayArg( T t1, T t2, T t3, T t4, T t5 )
243 {
244  T array[] = { t1, t2, t3, t4, t5 };
245  return ArrayArg<5,T>(array);
246 }
247 
252 template<class T>
253 inline TEUCHOS_DEPRECATED ArrayArg<6,T> arrayArg( T t1, T t2, T t3, T t4, T t5, T t6 )
254 {
255  T array[] = { t1, t2, t3, t4, t5, t6 };
256  return ArrayArg<6,T>(array);
257 }
258 
259 } // namespace Teuchos
260 
261 #endif // TEUCHOS_ARRAY_ARG_HPP
T * operator()()
Return a const pointer to the internal array.
Utility class that allows arrays to be passed into argument list.
ArrayArg(T array[])
Basic constructor taking a copy of the array of length N.
TEUCHOS_DEPRECATED ArrayArg< 1, T > arrayArg(T t1)
Return an array with 1 member.