ForEachTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_FOREACHTRAIT_H_
36 #define _BLAZE_MATH_TRAITS_FOREACHTRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
47 #include <blaze/util/DisableIf.h>
48 #include <blaze/util/EnableIf.h>
49 #include <blaze/util/InvalidType.h>
50 #include <blaze/util/mpl/If.h>
51 #include <blaze/util/mpl/Or.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // CLASS DEFINITION
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
77 template< typename T // Type of the operand
78  , typename OP > // Type of the custom operation
80 {
81  private:
82  //**********************************************************************************************
84  struct MatrixOrVector
85  {
86  template< typename U >
87  static DisableIf_< Or< IsVector<U>, IsMatrix<U> >, U > test( U&& );
88 
89  template< typename U >
90  static EnableIf_< Or< IsVector<U>, IsMatrix<U> >, ResultType_<U> > test( U&& );
91 
92  using RT = RemoveAdaptor_< ResultType_<T> >;
93  using RN = ReturnType_<T>;
94 
95  using OT = decltype( std::declval<OP>()( std::declval<RN>() ) );
96  using ET = decltype( test( std::declval<OT>() ) );
97 
98  using Type = typename RT::template Rebind<ET>::Other;
99  };
101  //**********************************************************************************************
102 
103  //**********************************************************************************************
105  struct Failure {
106  using Type = INVALID_TYPE;
107  };
109  //**********************************************************************************************
110 
111  //**********************************************************************************************
113  using Tmp = If_< Or< IsMatrix<T>, IsVector<T> >
114  , MatrixOrVector
115  , Failure >;
117  //**********************************************************************************************
118 
119  public:
120  //**********************************************************************************************
122  using Type = typename If_< Or< IsConst<T>, IsVolatile<T>, IsReference<T> >
124  , Tmp >::Type;
126  //**********************************************************************************************
127 };
128 //*************************************************************************************************
129 
130 
131 //*************************************************************************************************
144 template< typename T // Type of the operand
145  , typename OP > // Type of the custom operation
147 //*************************************************************************************************
148 
149 } // namespace blaze
150 
151 #endif
Header file for auxiliary alias declarations.
typename RemoveAdaptor< T >::Type RemoveAdaptor_
Auxiliary alias declaration for the RemoveAdaptor type trait.The RemoveAdaptor_ alias declaration pro...
Definition: RemoveAdaptor.h:153
Compile time check for volatile data types.The IsVolatile type trait tests whether or not the given t...
Definition: IsVolatile.h:75
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
Header file for the IsVolatile type trait.
Compile time check for matrix types.This type trait tests whether or not the given template parameter...
Definition: IsMatrix.h:78
Header file for the IsMatrix type trait.
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the Decay type trait.
Compile time check for vector types.This type trait tests whether or not the given template parameter...
Definition: IsVector.h:78
typename ForEachTrait< T, OP >::Type ForEachTrait_
Auxiliary alias declaration for the ForEachTrait class template.The ForEachTrait_ alias declaration p...
Definition: ForEachTrait.h:146
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Base template for the ForEachTrait class.The ForEachTrait class template offers the possibility to se...
Definition: ForEachTrait.h:79
Header file for the Or class template.
Header file for the RemoveAdaptor type trait.
Header file for the IsVector type trait.
Header file for the EnableIf class template.
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:160
Header file for the IsReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:75