SubTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_SUBTRAIT_H_
36 #define _BLAZE_MATH_TRAITS_SUBTRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/util/Complex.h>
45 #include <blaze/util/EnableIf.h>
46 #include <blaze/util/mpl/And.h>
47 #include <blaze/util/mpl/If.h>
48 #include <blaze/util/mpl/Or.h>
60 
61 
62 namespace blaze {
63 
64 //=================================================================================================
65 //
66 // CLASS DEFINITION
67 //
68 //=================================================================================================
69 
70 //*************************************************************************************************
140 template< typename T1 // Type of the left-hand side operand
141  , typename T2 // Type of the right-hand side operand
142  , typename = void > // Restricting condition
143 struct SubTrait
144 {
145  private:
146  //**********************************************************************************************
148  using Type1 = Decay_<T1>;
149  using Type2 = Decay_<T2>;
151  //**********************************************************************************************
152 
153  //**********************************************************************************************
155  struct NativeType { using Type = decltype( std::declval<Type1>() - std::declval<Type2>() ); };
157  //**********************************************************************************************
158 
159  //**********************************************************************************************
161  struct SignedType { using Type = MakeSigned_< typename NativeType::Type >; };
163  //**********************************************************************************************
164 
165  public:
166  //**********************************************************************************************
168  using Type = typename If_< Or< IsConst<T1>, IsVolatile<T1>, IsReference<T1>
172  , SignedType
173  , NativeType > >::Type;
175  //**********************************************************************************************
176 };
177 //*************************************************************************************************
178 
179 
180 //*************************************************************************************************
185 template< typename T1, typename T2 >
186 struct SubTrait< complex<T1>, T2, EnableIf_< IsBuiltin<T2> > >
187 {
188  public:
189  //**********************************************************************************************
190  using Type = CommonType_< complex<T1> , T2 >;
191  //**********************************************************************************************
192 };
194 //*************************************************************************************************
195 
196 
197 //*************************************************************************************************
202 template< typename T1, typename T2 >
203 struct SubTrait< T1, complex<T2>, EnableIf_< IsBuiltin<T1> > >
204 {
205  public:
206  //**********************************************************************************************
207  using Type = CommonType_< T1, complex<T2> >;
208  //**********************************************************************************************
209 };
211 //*************************************************************************************************
212 
213 
214 //*************************************************************************************************
219 template< typename T1, typename T2 >
220 struct SubTrait< complex<T1>, complex<T2> >
221 {
222  public:
223  //**********************************************************************************************
224  using Type = CommonType_< complex<T1>, complex<T2> >;
225  //**********************************************************************************************
226 };
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
244 template< typename T1, typename T2 >
246 //*************************************************************************************************
247 
248 } // namespace blaze
249 
250 #endif
Compile time check for volatile data types.The IsVolatile type trait tests whether or not the given t...
Definition: IsVolatile.h:75
typename Decay< T >::Type Decay_
Auxiliary alias declaration for the Decay type trait.The Decay_ alias declaration provides a convenie...
Definition: Decay.h:98
Header file for the IsIntegral type trait.
typename MakeSigned< T >::Type MakeSigned_
Auxiliary alias declaration for the MakeSigned type trait.The MakeSigned_ alias declaration provides ...
Definition: MakeSigned.h:99
Header file for the And class template.
Header file for the IsVolatile type trait.
Header file for the Decay type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the Or class template.
Compile time type check.This type trait determines whether the given type trait TypeTrait evaluates t...
Definition: Any.h:80
Header file for the EnableIf class template.
Header file for the CommonType type trait.
Header file for the IsConst type trait.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
Compile time check for built-in data types.This type trait tests whether or not the given template pa...
Definition: IsBuiltin.h:75
Header file for the IsSigned type trait.
Header file for the IsReference type trait.
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:75
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the All type trait.
Header file for the IsBuiltin type trait.
typename SubTrait< T1, T2 >::Type SubTrait_
Auxiliary alias declaration for the SubTrait class template.The SubTrait_ alias declaration provides ...
Definition: SubTrait.h:245
typename CommonType< T... >::Type CommonType_
Auxiliary alias declaration for the CommonType type trait.The CommonType_ alias declaration provides ...
Definition: CommonType.h:95
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:75
Header file for the Any type trait.
Header file for the complex data type.
Base template for the SubTrait class.
Definition: SubTrait.h:143
Header file for the MakeSigned type trait.