IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
CompatibleType32.h
1 // CompatibleType32.h:
3 // -------------------
4 //
15 
16 #ifndef __IPSDKUTIL_INSTRUCTIONSET_COMPATIBLETYPE32_H__
17 #define __IPSDKUTIL_INSTRUCTIONSET_COMPATIBLETYPE32_H__
18 
19 #include <IPSDKUtil/BaseTypes.h>
21 #include <boost/type_traits/is_integral.hpp>
22 #include <boost/type_traits/is_unsigned.hpp>
23 #include <boost/type_traits/is_float.hpp>
24 #include <boost/type_traits/is_integral.hpp>
25 #include <boost/type_traits/make_signed.hpp>
26 #include <boost/mpl/if.hpp>
27 #include <boost/mpl/greater_equal.hpp>
28 #include <boost/mpl/sizeof.hpp>
29 #include <boost/mpl/and.hpp>
30 
31 namespace ipsdk {
32 
35 
36 template <typename T1, typename T2,
37  typename Enable=void>
38 struct CompatibleType32;
39 
42 
44 
45 // specialization of CompatibleType32 with T1 and T2 equal to ipReal32
46 template <typename T1, typename T2>
47 struct CompatibleType32<T1, T2, typename boost::enable_if<typename boost::mpl::and_<
48  boost::is_float<T1>,
49  boost::is_float<T2>
50  >::type>::type>
51 {
52  typedef ipReal32 Type;
53 };
54 
55 // specialization of CompatibleType32 with T1 equal to ipReal32 and T2 equal to integer type
56 template <typename T1, typename T2>
57 struct CompatibleType32<T1, T2, typename boost::enable_if<typename boost::mpl::and_<
58  boost::is_float<T1>,
59  boost::is_integral<T2>
60  >::type>::type>
61 {
62  typedef ipReal32 Type;
63 };
64 
65 // specialization of CompatibleType32 with T1 equal to integer type and T2 equal to ipReal32
66 template <typename T1, typename T2>
67 struct CompatibleType32<T1, T2, typename boost::enable_if<typename boost::mpl::and_<
68  boost::is_integral<T1>,
69  boost::is_float<T2>
70  >::type>::type>
71 {
72  typedef ipReal32 Type;
73 };
74 
75 // specialization of CompatibleType32 with T1 and T2 equal to integer types
76 template <typename T1, typename T2>
77 struct CompatibleType32<T1, T2, typename boost::enable_if<typename boost::mpl::and_<
78  boost::is_integral<T1>,
79  boost::is_integral<T2>
80  >::type>::type>
81 {
82  typedef typename boost::mpl::if_<
83  // T1 is unsigned ?
84  boost::is_unsigned<T1>,
85  // T1 is unsigned
86  typename boost::mpl::if_<
87  // T2 is unsigned ?
88  boost::is_unsigned<T2>,
89  // T1 and T2 are unsigned
90  typename boost::mpl::if_<
91  // sizeof(T1) >= sizeof(T2) ?
92  boost::mpl::greater_equal<boost::mpl::sizeof_<T1>, boost::mpl::sizeof_<T2> >,
93  T1,
94  T2
95  >::type,
96  // T1 is unsigned and T2 is signed
97  typename boost::mpl::if_<
98  // sizeof(T1) >= sizeof(T2) ?
99  boost::mpl::greater_equal<boost::mpl::sizeof_<T1>, boost::mpl::sizeof_<T2> >,
100  typename boost::make_signed<typename UpperType32<T1>::Type>::type,
101  T2
102  >::type
103  >::type,
104  // T1 is signed
105  typename boost::mpl::if_<
106  // T2 is unsigned ?
107  boost::is_unsigned<T2>,
108  // T1 is signed and T2 is unsigned
109  typename boost::mpl::if_<
110  // sizeof(T2) >= sizeof(T1) ?
111  boost::mpl::greater_equal<boost::mpl::sizeof_<T2>, boost::mpl::sizeof_<T1> >,
112  typename boost::make_signed<typename UpperType32<T2>::Type>::type,
113  T1
114  >::type,
115  // T1 and T2 are signed
116  typename boost::mpl::if_<
117  // sizeof(T1) >= sizeof(T2) ?
118  boost::mpl::greater_equal<boost::mpl::sizeof_<T1>, boost::mpl::sizeof_<T2> >,
119  T1,
120  T2
121  >::type
122  >::type
123  >::type Type;
124 };
125 
128 
129 } // end of namespace ipsdk
130 
132 
133 #endif // __IPSDKUTIL_INSTRUCTIONSET_COMPATIBLETYPE32_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: DataItemNodeHdrMacrosDetails.h:48
template structures used for immediate type promotion
Base types for multiplatform compatibility.
defines template structure CompatibleType32<T1, T2>
float ipReal32
Base types definition.
Definition: BaseTypes.h:56