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/If.h>
47 #include <blaze/util/mpl/Or.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // CLASS DEFINITION
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
136 template< typename T1 // Type of the left-hand side operand
137  , typename T2 // Type of the right-hand side operand
138  , typename = void > // Restricting condition
139 struct SubTrait
140 {
141  private:
142  //**********************************************************************************************
144  using Type1 = Decay_<T1>;
145  using Type2 = Decay_<T2>;
147  //**********************************************************************************************
148 
149  //**********************************************************************************************
151  struct SubType { using Type = decltype( std::declval<Type1>() - std::declval<Type2>() ); };
153  //**********************************************************************************************
154 
155  public:
156  //**********************************************************************************************
158  using Type = typename If_< Or< IsConst<T1>, IsVolatile<T1>, IsReference<T1>
161  , SubType >::Type;
163  //**********************************************************************************************
164 };
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
173 template< typename T >
174 struct SubTrait< T, T, EnableIf_< IsBuiltin<T> > >
175 {
176  public:
177  //**********************************************************************************************
178  using Type = Decay_<T>;
179  //**********************************************************************************************
180 };
182 //*************************************************************************************************
183 
184 
185 //*************************************************************************************************
190 template< typename T1, typename T2 >
191 struct SubTrait< complex<T1>, T2, EnableIf_< IsBuiltin<T2> > >
192 {
193  public:
194  //**********************************************************************************************
195  using Type = CommonType_< complex<T1> , T2 >;
196  //**********************************************************************************************
197 };
199 //*************************************************************************************************
200 
201 
202 //*************************************************************************************************
207 template< typename T1, typename T2 >
208 struct SubTrait< T1, complex<T2>, EnableIf_< IsBuiltin<T1> > >
209 {
210  public:
211  //**********************************************************************************************
212  using Type = CommonType_< T1, complex<T2> >;
213  //**********************************************************************************************
214 };
216 //*************************************************************************************************
217 
218 
219 //*************************************************************************************************
224 template< typename T1, typename T2 >
225 struct SubTrait< complex<T1>, complex<T2> >
226 {
227  public:
228  //**********************************************************************************************
229  using Type = CommonType_< complex<T1>, complex<T2> >;
230  //**********************************************************************************************
231 };
233 //*************************************************************************************************
234 
235 
236 //*************************************************************************************************
249 template< typename T1, typename T2 >
251 //*************************************************************************************************
252 
253 } // namespace blaze
254 
255 #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 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.
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:154
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
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:250
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:139