Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShDataTypeImpl.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHDATATYPEIMPL_HPP
00021 #define SHDATATYPEIMPL_HPP
00022 
00023 #include <climits>
00024 #include <cmath>
00025 #include <algorithm>
00026 #include "ShDataType.hpp"
00027 
00028 namespace SH {
00029 
00031 template<typename T, ShDataType DT>
00032 inline
00033 typename ShDataTypeCppType<T, DT>::type shDataTypeCond(bool cond) 
00034 {
00035   return cond ? ShDataTypeConstant<T, DT>::One : ShDataTypeConstant<T, DT>::Zero;
00036 }
00037 
00042 template<typename T>
00043 inline
00044 bool shDataTypeEqual(const T &a, 
00045                      const T &b) 
00046 {
00047   return a == b;
00048 }
00049 
00050 // @}
00051 
00055 template<typename T>
00056 inline
00057 bool shDataTypeIsPositive(const T &a)
00058 {
00059   return a > 0; 
00060 }
00061 
00063 
00068 template<typename T1, ShDataType DT1, typename T2, ShDataType DT2>
00069 void shDataTypeCast(typename ShDataTypeCppType<T1, DT1>::type &dest,
00070                     const typename ShDataTypeCppType<T2, DT2>::type &src)
00071 {
00072   typedef typename ShDataTypeCppType<T1, DT1>::type desttype; 
00073   dest = static_cast<desttype>(src);
00074 }
00075 
00076 
00077 }
00078 
00079 #endif

Generated on Thu Jul 28 17:33:02 2005 for Sh by  doxygen 1.4.3-20050530