Blaze 3.9
LowType.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_TYPETRAITS_LOWTYPE_H_
36#define _BLAZE_MATH_TYPETRAITS_LOWTYPE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/util/Complex.h>
44#include <blaze/util/EnableIf.h>
46#include <blaze/util/mpl/If.h>
51
52
53namespace blaze {
54
55//=================================================================================================
56//
57// CLASS DEFINITION
58//
59//=================================================================================================
60
61//*************************************************************************************************
66template< typename T1 // First operand
67 , typename T2 // Second operand
68 , typename = void > // Restricting condition
69struct LowTypeHelper
70{
71 public:
72 //**********************************************************************************************
73 using Type = INVALID_TYPE;
74 //**********************************************************************************************
75};
77//*************************************************************************************************
78
79
80//*************************************************************************************************
85template< typename T1, typename T2 >
86struct LowTypeHelper< T1, T2
87 , EnableIf_t< IsIntegral_v<T1> &&
88 IsIntegral_v<T2> &&
89 ( sizeof( T1 ) < sizeof( T2 ) ) > >
90{
91 public:
92 //**********************************************************************************************
93 using Type = T1;
94 //**********************************************************************************************
95};
97//*************************************************************************************************
98
99
100//*************************************************************************************************
105template< typename T1, typename T2 >
106struct LowTypeHelper< T1, T2
107 , EnableIf_t< IsIntegral_v<T1> &&
108 IsIntegral_v<T2> &&
109 ( sizeof( T1 ) > sizeof( T2 ) ) > >
110{
111 public:
112 //**********************************************************************************************
113 using Type = T2;
114 //**********************************************************************************************
115};
117//*************************************************************************************************
118
119
120//*************************************************************************************************
125template< typename T1, typename T2 >
126struct LowTypeHelper< T1, T2
127 , EnableIf_t< IsIntegral_v<T1> &&
128 IsIntegral_v<T2> &&
129 ( sizeof( T1 ) == sizeof( T2 ) ) > >
130{
131 public:
132 //**********************************************************************************************
133 using Type = If_t< IsSigned_v<T1>, T2, T1 >;
134 //**********************************************************************************************
135};
137//*************************************************************************************************
138
139
140//*************************************************************************************************
145template< typename T1, typename T2 >
146struct LowTypeHelper< T1, T2
147 , EnableIf_t< IsIntegral_v<T1> && IsFloatingPoint_v<T2> > >
148{
149 public:
150 //**********************************************************************************************
151 using Type = T1;
152 //**********************************************************************************************
153};
155//*************************************************************************************************
156
157
158//*************************************************************************************************
163template< typename T1, typename T2 >
164struct LowTypeHelper< T1, T2
165 , EnableIf_t< IsFloatingPoint_v<T1> && IsIntegral_v<T2> > >
166{
167 public:
168 //**********************************************************************************************
169 using Type = T2;
170 //**********************************************************************************************
171};
173//*************************************************************************************************
174
175
176//*************************************************************************************************
181template< typename T1, typename T2 >
182struct LowTypeHelper< T1, T2
183 , EnableIf_t< IsFloatingPoint_v<T1> && IsFloatingPoint_v<T2> > >
184{
185 public:
186 //**********************************************************************************************
187 using Type = If_t< ( sizeof( T1 ) < sizeof( T2 ) ), T1, T2 >;
188 //**********************************************************************************************
189};
191//*************************************************************************************************
192
193
194//*************************************************************************************************
199template< typename T1, typename T2 >
200struct LowTypeHelper< T1, T2
201 , EnableIf_t< IsComplex_v<T1> && !IsComplex_v<T2> > >
202{
203 public:
204 //**********************************************************************************************
205 using Type = T2;
206 //**********************************************************************************************
207};
209//*************************************************************************************************
210
211
212//*************************************************************************************************
217template< typename T1, typename T2 >
218struct LowTypeHelper< T1, T2
219 , EnableIf_t< !IsComplex_v<T1> && IsComplex_v<T2> > >
220{
221 public:
222 //**********************************************************************************************
223 using Type = T1;
224 //**********************************************************************************************
225};
227//*************************************************************************************************
228
229
230//*************************************************************************************************
235template< typename T1, typename T2 >
236struct LowTypeHelper< T1, T2
237 , EnableIf_t< IsComplex_v<T1> && IsComplex_v<T2> > >
238{
239 public:
240 //**********************************************************************************************
242 //**********************************************************************************************
243};
245//*************************************************************************************************
246
247
248//*************************************************************************************************
318template< typename T1 // First operand
319 , typename T2 // Second operand
320 , typename = void > // Restricting condition
322{
323 public:
324 //**********************************************************************************************
326 using Type = typename LowTypeHelper<T1,T2>::Type;
328 //**********************************************************************************************
329};
330//*************************************************************************************************
331
332
333//*************************************************************************************************
346template< typename T1 // First operand
347 , typename T2 > // Second operand
349//*************************************************************************************************
350
351} // namespace blaze
352
353#endif
Header file for the complex data type.
Header file for the EnableIf class template.
Header file for the If class template.
Utility type for generic codes.
Header file for the IsComplex type trait.
Header file for the IsFloatingPoint type trait.
Header file for the IsIntegral type trait.
Header file for the IsSigned type trait.
Complex data type of the Blaze library.
typename LowType< T1, T2 >::Type LowType_t
Auxiliary alias declaration for the LowType type trait.
Definition: LowType.h:348
constexpr bool IsFloatingPoint_v
Auxiliary variable template for the IsFloatingPoint type trait.
Definition: IsFloatingPoint.h:95
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition: IsIntegral.h:95
constexpr bool IsComplex_v
Auxiliary variable template for the IsComplex type trait.
Definition: IsComplex.h:139
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
Base template for the LowType type trait.
Definition: LowType.h:322