AddTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_ADDTRAIT_H_
36 #define _BLAZE_MATH_TRAITS_ADDTRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <boost/typeof/typeof.hpp>
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>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // CLASS DEFINITION
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
135 template< typename T1 // Type of the left-hand side operand
136  , typename T2 // Type of the right-hand side operand
137  , typename = void > // Restricting condition
138 struct AddTrait
139 {
140  private:
141  //**********************************************************************************************
143  typedef typename RemoveReference< typename RemoveCV<T1>::Type >::Type Type1;
144  typedef typename RemoveReference< typename RemoveCV<T2>::Type >::Type Type2;
146  //**********************************************************************************************
147 
148  //**********************************************************************************************
150  struct AddType { typedef BOOST_TYPEOF_TPL( Type1() + Type2() ) Type; };
152  //**********************************************************************************************
153 
154  public:
155  //**********************************************************************************************
159  , AddTrait<Type1,Type2>, AddType >::Type::Type Type;
161  //**********************************************************************************************
162 };
163 //*************************************************************************************************
164 
165 
166 //*************************************************************************************************
171 template< typename T1, typename T2 >
172 struct AddTrait< complex<T1>, T2, typename EnableIf< IsBuiltin<T2> >::Type >
173 {
174  public:
175  //**********************************************************************************************
176  typedef typename CommonType< complex<T1> , T2 >::Type Type;
177  //**********************************************************************************************
178 };
180 //*************************************************************************************************
181 
182 
183 //*************************************************************************************************
188 template< typename T1, typename T2 >
189 struct AddTrait< T1, complex<T2>, typename EnableIf< IsBuiltin<T1> >::Type >
190 {
191  public:
192  //**********************************************************************************************
193  typedef typename CommonType< T1, complex<T2> >::Type Type;
194  //**********************************************************************************************
195 };
197 //*************************************************************************************************
198 
199 
200 //*************************************************************************************************
205 template< typename T1, typename T2 >
206 struct AddTrait< complex<T1>, complex<T2> >
207 {
208  public:
209  //**********************************************************************************************
210  typedef typename CommonType< complex<T1>, complex<T2> >::Type Type;
211  //**********************************************************************************************
212 };
214 //*************************************************************************************************
215 
216 } // namespace blaze
217 
218 #endif
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
Compile time check for volatile data types.The IsVolatile type trait tests whether or not the given t...
Definition: IsVolatile.h:94
Header file for the RemoveCV type trait.
Header file for the IsVolatile type trait.
Deduction of a type common to several types.The CommonType type trait deduces a type that is common t...
Definition: CommonType.h:70
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.
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for the IsConst type trait.
Base template for the AddTrait class.
Definition: AddTrait.h:138
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Compile time check for built-in data types.This type trait tests whether or not the given template pa...
Definition: IsBuiltin.h:94
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
Header file for the IsBuiltin type trait.
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:94
Header file for the complex data type.