MultTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_MULTTRAIT_H_
36 #define _BLAZE_MATH_TRAITS_MULTTRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
48 #include <blaze/util/Complex.h>
49 #include <blaze/util/EnableIf.h>
50 #include <blaze/util/InvalidType.h>
51 #include <blaze/util/mpl/And.h>
52 #include <blaze/util/mpl/If.h>
53 #include <blaze/util/mpl/Not.h>
54 #include <blaze/util/mpl/Or.h>
61 
62 
63 namespace blaze {
64 
65 //=================================================================================================
66 //
67 // CLASS DEFINITION
68 //
69 //=================================================================================================
70 
71 //*************************************************************************************************
116 template< typename T1 // Type of the left-hand side operand
117  , typename T2 // Type of the right-hand side operand
118  , typename = void > // Restricting condition
119 struct MultTrait
120 {
121  private:
122  //**********************************************************************************************
124  struct MultType { using Type = decltype( std::declval<T1>() * std::declval<T2>() ); };
126  //**********************************************************************************************
127 
128  //**********************************************************************************************
130  struct Failure { using Type = INVALID_TYPE; };
132  //**********************************************************************************************
133 
134  public:
135  //**********************************************************************************************
137  using Type = typename If_< Or< IsConst<T1>, IsVolatile<T1>, IsReference<T1>
141  , MultType
142  , Failure > >::Type;
144  //**********************************************************************************************
145 };
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
154 template< typename T >
155 struct MultTrait< T, T, EnableIf_< IsBuiltin<T> > >
156 {
157  public:
158  //**********************************************************************************************
159  using Type = Decay_<T>;
160  //**********************************************************************************************
161 };
163 //*************************************************************************************************
164 
165 
166 //*************************************************************************************************
171 template< typename T1, typename T2 >
172 struct MultTrait< complex<T1>, T2, EnableIf_< IsBuiltin<T2> > >
173 {
174  public:
175  //**********************************************************************************************
176  using Type = CommonType_< complex<T1> , T2 >;
177  //**********************************************************************************************
178 };
180 //*************************************************************************************************
181 
182 
183 //*************************************************************************************************
188 template< typename T1, typename T2 >
189 struct MultTrait< T1, complex<T2>, EnableIf_< IsBuiltin<T1> > >
190 {
191  public:
192  //**********************************************************************************************
193  using Type = CommonType_< T1, complex<T2> >;
194  //**********************************************************************************************
195 };
197 //*************************************************************************************************
198 
199 
200 //*************************************************************************************************
205 template< typename T1, typename T2 >
206 struct MultTrait< complex<T1>, complex<T2> >
207 {
208  public:
209  //**********************************************************************************************
210  using Type = CommonType_< complex<T1>, complex<T2> >;
211  //**********************************************************************************************
212 };
214 //*************************************************************************************************
215 
216 
217 //*************************************************************************************************
223 template< typename T1, typename T2 >
224 struct MultTrait< T1, T2
225  , EnableIf_< And< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> >
226  , Not< Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > > >
227 {
228  public:
229  //**********************************************************************************************
231  //**********************************************************************************************
232 };
234 //*************************************************************************************************
235 
236 
237 //*************************************************************************************************
243 template< typename T1, typename T2 >
244 struct MultTrait< T1, T2
245  , EnableIf_< And< Not< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> > >
246  , Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > >
247 {
248  public:
249  //**********************************************************************************************
251  //**********************************************************************************************
252 };
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
263 template< typename T1, typename T2 >
264 struct MultTrait< T1, T2
265  , EnableIf_< And< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> >
266  , Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > >
267 {
268  public:
269  //**********************************************************************************************
271  //**********************************************************************************************
272 };
274 //*************************************************************************************************
275 
276 
277 //*************************************************************************************************
290 template< typename T1, typename T2 >
292 //*************************************************************************************************
293 
294 } // namespace blaze
295 
296 #endif
Header file for the IsInitializer type trait.
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 And class template.
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Header file for the IsVolatile type trait.
Header file for the Decay type trait.
Header file for the IsCustom type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the Or class template.
Header file for the HasMult type trait.
Header file for the Not class template.
Header file for the EnableIf class template.
Header file for the IsView type trait.
Header file for the CommonType type trait.
Header file for the IsConst type trait.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:119
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 IsBuiltin type trait.
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 complex data type.