Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
typetraits
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
>
45
#include <
blaze/util/InvalidType.h
>
46
#include <
blaze/util/mpl/If.h
>
47
#include <
blaze/util/typetraits/IsComplex.h
>
48
#include <
blaze/util/typetraits/IsFloatingPoint.h
>
49
#include <
blaze/util/typetraits/IsIntegral.h
>
50
#include <
blaze/util/typetraits/IsSigned.h
>
51
52
53
namespace
blaze {
54
55
//=================================================================================================
56
//
57
// CLASS DEFINITION
58
//
59
//=================================================================================================
60
61
//*************************************************************************************************
66
template
<
typename
T1
// First operand
67
,
typename
T2
// Second operand
68
,
typename
=
void
>
// Restricting condition
69
struct
LowTypeHelper
70
{
71
public
:
72
//**********************************************************************************************
73
using
Type = INVALID_TYPE;
74
//**********************************************************************************************
75
};
77
//*************************************************************************************************
78
79
80
//*************************************************************************************************
85
template
<
typename
T1,
typename
T2 >
86
struct
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
//*************************************************************************************************
105
template
<
typename
T1,
typename
T2 >
106
struct
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
//*************************************************************************************************
125
template
<
typename
T1,
typename
T2 >
126
struct
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
//*************************************************************************************************
145
template
<
typename
T1,
typename
T2 >
146
struct
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
//*************************************************************************************************
163
template
<
typename
T1,
typename
T2 >
164
struct
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
//*************************************************************************************************
181
template
<
typename
T1,
typename
T2 >
182
struct
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
//*************************************************************************************************
199
template
<
typename
T1,
typename
T2 >
200
struct
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
//*************************************************************************************************
217
template
<
typename
T1,
typename
T2 >
218
struct
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
//*************************************************************************************************
235
template
<
typename
T1,
typename
T2 >
236
struct
LowTypeHelper< T1, T2
237
,
EnableIf_t
<
IsComplex_v
<T1> &&
IsComplex_v<T2>
> >
238
{
239
public
:
240
//**********************************************************************************************
241
using
Type
= complex< typename LowTypeHelper< typename T1::value_type, typename T2::value_type >::Type >;
242
//**********************************************************************************************
243
};
245
//*************************************************************************************************
246
247
248
//*************************************************************************************************
318
template
<
typename
T1
// First operand
319
,
typename
T2
// Second operand
320
,
typename
=
void
>
// Restricting condition
321
struct
LowType
322
{
323
public
:
324
//**********************************************************************************************
326
using
Type
=
typename
LowTypeHelper<T1,T2>::Type;
328
//**********************************************************************************************
329
};
330
//*************************************************************************************************
331
332
333
//*************************************************************************************************
346
template
<
typename
T1
// First operand
347
,
typename
T2 >
// Second operand
348
using
LowType_t
=
typename
LowType<T1,T2>::Type
;
349
//*************************************************************************************************
350
351
}
// namespace blaze
352
353
#endif
Complex.h
Header file for the complex data type.
EnableIf.h
Header file for the EnableIf class template.
If.h
Header file for the If class template.
InvalidType.h
Utility type for generic codes.
IsComplex.h
Header file for the IsComplex type trait.
IsFloatingPoint.h
Header file for the IsFloatingPoint type trait.
IsIntegral.h
Header file for the IsIntegral type trait.
IsSigned.h
Header file for the IsSigned type trait.
blaze::Type
blaze::LowType_t
typename LowType< T1, T2 >::Type LowType_t
Auxiliary alias declaration for the LowType type trait.
Definition
LowType.h:348
blaze::IsFloatingPoint_v
constexpr bool IsFloatingPoint_v
Auxiliary variable template for the IsFloatingPoint type trait.
Definition
IsFloatingPoint.h:95
blaze::IsIntegral_v
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition
IsIntegral.h:95
blaze::IsComplex_v
constexpr bool IsComplex_v
Auxiliary variable template for the IsComplex type trait.
Definition
IsComplex.h:139
blaze::EnableIf_t
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition
EnableIf.h:138
blaze::If_t
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition
If.h:108
blaze::LowType
Base template for the LowType type trait.
Definition
LowType.h:322
Generated by
1.18.0