[80] | 1 | // -*- C++ -*- |
---|
| 2 | /*************************************************************************** |
---|
| 3 | * blitz/meta/metaprog.h Useful metaprogram declarations |
---|
| 4 | * |
---|
| 5 | * $Id: metaprog.h,v 1.6 2005/05/07 04:17:57 julianc Exp $ |
---|
| 6 | * |
---|
| 7 | * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * Suggestions: blitz-dev@oonumerics.org |
---|
| 20 | * Bugs: blitz-bugs@oonumerics.org |
---|
| 21 | * |
---|
| 22 | * For more information, please see the Blitz++ Home Page: |
---|
| 23 | * http://oonumerics.org/blitz/ |
---|
| 24 | * |
---|
| 25 | ***************************************************************************/ |
---|
| 26 | |
---|
| 27 | #ifndef BZ_META_METAPROG_H |
---|
| 28 | #define BZ_META_METAPROG_H |
---|
| 29 | |
---|
| 30 | BZ_NAMESPACE(blitz) |
---|
| 31 | |
---|
| 32 | // Null Operand |
---|
| 33 | |
---|
| 34 | class _bz_meta_nullOperand { |
---|
| 35 | public: |
---|
| 36 | _bz_meta_nullOperand() { } |
---|
| 37 | }; |
---|
| 38 | |
---|
| 39 | template<typename T> inline T operator+(const T& a, _bz_meta_nullOperand) |
---|
| 40 | { return a; } |
---|
| 41 | template<typename T> inline T operator*(const T& a, _bz_meta_nullOperand) |
---|
| 42 | { return a; } |
---|
| 43 | |
---|
| 44 | // MetaMax |
---|
| 45 | |
---|
| 46 | template<int N1, int N2> |
---|
| 47 | class _bz_meta_max { |
---|
| 48 | public: |
---|
| 49 | static const int max = (N1 > N2) ? N1 : N2; |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | // MetaMin |
---|
| 53 | |
---|
| 54 | template<int N1, int N2> |
---|
| 55 | class _bz_meta_min { |
---|
| 56 | public: |
---|
| 57 | static const int min = (N1 < N2) ? N1 : N2; |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | BZ_NAMESPACE_END |
---|
| 61 | |
---|
| 62 | #endif // BZ_META_METAPROG_H |
---|