Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members

tmpltool.h

00001 /* -*- c++ -*- */
00002 /*
00003  * Expresso, a C++ Array template class library
00004  * Copyright (C) 1998,2004 Oskar Enoksson (enok@lysator.liu.se)
00005  * 
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA  02111-1307, USA.
00020  */
00021 #ifndef EXPRESSO_TMPLTOOL_HDR
00022 #define EXPRESSO_TMPLTOOL_HDR
00023 
00024 namespace TmplTools {
00025   template<bool B>
00026   struct TAssert;
00027 
00028   template<>
00029   struct TAssert<true> {};
00030 
00031   template<>
00032   struct TAssert<false>;
00033 
00034   template<class T1, class T2>
00035   struct IsSame {
00036     enum { check=0 };
00037   };
00038 
00039   template<class T1>
00040   struct IsSame<T1,T1> {
00041     enum { check=1 };
00042   };
00043 
00044   template<class T0>
00045   struct UnConst {
00046     typedef T0 T;
00047   };
00048 
00049   template<class T0>
00050   struct UnConst<const T0> {
00051     typedef T0 T;
00052   };
00053 
00054   template<class T0>
00055   struct FlipConst {
00056     typedef const T0 T;
00057   };
00058 
00059   template<class T0>
00060   struct FlipConst<const T0> {
00061     typedef T0 T;
00062   };
00063 
00064   template<int N1, int N2, bool B=(N1>N2)>
00065   struct Max;
00066 
00067   template<int N1, int N2>
00068   struct Max<N1,N2,true> {
00069     enum { value = N1 };
00070   };
00071   template<int N1, int N2>
00072   struct Max<N1,N2,false> {
00073     enum { value = N2 };
00074   };
00075 
00076   template<class T0>
00077   struct ArrayInfo {
00078     typedef T0 RecurseType;
00079     typedef T0 T;
00080     enum { len=1 };
00081     enum { totlen=1 };
00082     enum { rank=0 };
00083   };
00084   
00085   template<class T0, int M>
00086   struct ArrayInfo<T0[M]> {
00087     typedef T0 RecurseType;
00088     typedef typename ArrayInfo<T0>::T T;
00089     enum { len=M };
00090     enum { totlen=len*ArrayInfo<T0>::totlen };
00091     enum { rank=1+ArrayInfo<T0>::rank };
00092   };
00093   
00094   template<class T0, int N>
00095   struct ArrayInfoIndex {
00096     enum { stride=ArrayInfo<T0>::len*
00097            ArrayInfoIndex<typename ArrayInfo<T0>::RecurseType,N-1>::stride };
00098     enum { len=ArrayInfoIndex<typename ArrayInfo<T0>::RecurseType,N-1>::len };
00099   };
00100   
00101   template<class T0>
00102   struct ArrayInfoIndex<T0,0> {
00103     enum { stride=1 };
00104     enum { len=ArrayInfo<T0>::len };
00105   };
00106 
00107 }
00108 
00109 #endif

Generated on Wed May 12 13:34:34 2004 for Expresso by doxygen 1.3.3