00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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