DivTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_DIVTRAIT_H_
36 #define _BLAZE_MATH_TRAITS_DIVTRAIT_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 //*************************************************************************************************
117 template< typename T1 // Type of the left-hand side operand
118  , typename T2 // Type of the right-hand side operand
119  , typename = void > // Restricting condition
120 struct DivTrait
121 {
122  private:
123  //**********************************************************************************************
125  struct DivType { using Type = decltype( std::declval<T1>() / std::declval<T2>() ); };
127  //**********************************************************************************************
128 
129  //**********************************************************************************************
131  struct Failure { using Type = INVALID_TYPE; };
133  //**********************************************************************************************
134 
135  public:
136  //**********************************************************************************************
138  using Type = typename If_< Or< IsConst<T1>, IsVolatile<T1>, IsReference<T1>
142  , DivType
143  , Failure > >::Type;
145  //**********************************************************************************************
146 };
147 //*************************************************************************************************
148 
149 
150 //*************************************************************************************************
155 template< typename T >
156 struct DivTrait< T, T, EnableIf_< IsBuiltin<T> > >
157 {
158  public:
159  //**********************************************************************************************
160  using Type = Decay_<T>;
161  //**********************************************************************************************
162 };
164 //*************************************************************************************************
165 
166 
167 //*************************************************************************************************
172 template< typename T1, typename T2 >
173 struct DivTrait< complex<T1>, T2, EnableIf_< IsBuiltin<T2> > >
174 {
175  public:
176  //**********************************************************************************************
177  using Type = CommonType_< complex<T1> , T2 >;
178  //**********************************************************************************************
179 };
181 //*************************************************************************************************
182 
183 
184 //*************************************************************************************************
189 template< typename T1, typename T2 >
190 struct DivTrait< T1, complex<T2>, EnableIf_< IsBuiltin<T1> > >
191 {
192  public:
193  //**********************************************************************************************
194  using Type = CommonType_< T1, complex<T2> >;
195  //**********************************************************************************************
196 };
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
206 template< typename T1, typename T2 >
207 struct DivTrait< complex<T1>, complex<T2> >
208 {
209  public:
210  //**********************************************************************************************
211  using Type = CommonType_< complex<T1>, complex<T2> >;
212  //**********************************************************************************************
213 };
215 //*************************************************************************************************
216 
217 
218 //*************************************************************************************************
224 template< typename T1, typename T2 >
225 struct DivTrait< T1, T2
226  , EnableIf_< And< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> >
227  , Not< Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > > >
228 {
229  public:
230  //**********************************************************************************************
231  using Type = typename DivTrait< typename T1::ResultType, T2 >::Type;
232  //**********************************************************************************************
233 };
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
244 template< typename T1, typename T2 >
245 struct DivTrait< T1, T2
246  , EnableIf_< And< Not< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> > >
247  , Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > >
248 {
249  public:
250  //**********************************************************************************************
251  using Type = typename DivTrait< T1, typename T2::ResultType >::Type;
252  //**********************************************************************************************
253 };
255 //*************************************************************************************************
256 
257 
258 //*************************************************************************************************
264 template< typename T1, typename T2 >
265 struct DivTrait< T1, T2
266  , EnableIf_< And< Or< IsCustom<T1>, IsInitializer<T1>, IsView<T1> >
267  , Or< IsCustom<T2>, IsInitializer<T2>, IsView<T2> > > > >
268 {
269  public:
270  //**********************************************************************************************
272  //**********************************************************************************************
273 };
275 //*************************************************************************************************
276 
277 
278 //*************************************************************************************************
291 template< typename T1, typename T2 >
293 //*************************************************************************************************
294 
295 } // namespace blaze
296 
297 #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.
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 Not class template.
Header file for the EnableIf class template.
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:292
Header file for the IsView type trait.
Header file for the CommonType type trait.
Header file for the HasDiv type trait.
Header file for the IsConst type trait.
Utility type for generic codes.
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
Base template for the DivTrait class.
Definition: DivTrait.h:120
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.