ReduceTrait.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TRAITS_REDUCETRAIT_H_
36 #define _BLAZE_MATH_TRAITS_REDUCETRAIT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/Aliases.h>
45 #include <blaze/util/InvalidType.h>
46 #include <blaze/util/Types.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // CLASS DEFINITION
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
60 template< typename, typename, size_t... > struct ReduceTrait;
61 template< typename, typename, typename = void > struct TotalReduceTraitEval1;
62 template< typename, typename, typename = void > struct TotalReduceTraitEval2;
63 template< typename, typename, size_t, typename = void > struct PartialReduceTraitEval1;
64 template< typename, typename, size_t, typename = void > struct PartialReduceTraitEval2;
66 //*************************************************************************************************
67 
68 
69 //*************************************************************************************************
71 template< size_t RF, typename T, typename OP >
72 auto evalReduceTrait( T&, OP )
73  -> typename PartialReduceTraitEval1<T,OP,RF>::Type;
74 
75 template< typename T, typename OP >
76 auto evalReduceTrait( T&, OP )
77  -> typename TotalReduceTraitEval1<T,OP>::Type;
78 
79 template< size_t RF, typename T, typename OP >
80 auto evalReduceTrait( const T&, OP )
81  -> typename ReduceTrait<T,OP,RF>::Type;
82 
83 template< typename T, typename OP >
84 auto evalReduceTrait( const T&, OP )
85  -> typename ReduceTrait<T,OP>::Type;
86 
87 template< size_t RF, typename T, typename OP >
88 auto evalReduceTrait( const volatile T&, OP )
89  -> typename ReduceTrait<T,OP,RF>::Type;
90 
91 template< typename T, typename OP >
92 auto evalReduceTrait( const volatile T&, OP )
93  -> typename ReduceTrait<T,OP>::Type;
95 //*************************************************************************************************
96 
97 
98 //*************************************************************************************************
143 template< typename T // Type of the operand
144  , typename OP // Type of the reduction operation
145  , size_t... RF > // Reduction flag
147 {
148  public:
149  //**********************************************************************************************
151  using Type = decltype( evalReduceTrait<RF...>( std::declval<T&>(), std::declval<OP>() ) );
153  //**********************************************************************************************
154 };
155 //*************************************************************************************************
156 
157 
158 //*************************************************************************************************
171 template< typename T // Type of the operand
172  , typename OP // Type of the reduction operation
173  , size_t... RF > // Reduction flag
174 using ReduceTrait_t = typename ReduceTrait<T,OP,RF...>::Type;
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
183 template< typename T // Type of the operand
184  , typename OP // Type of the custom operation
185  , typename > // Restricting condition
186 struct TotalReduceTraitEval1
187 {
188  public:
189  //**********************************************************************************************
190  using Type = typename TotalReduceTraitEval2<T,OP>::Type;
191  //**********************************************************************************************
192 };
194 //*************************************************************************************************
195 
196 
197 //*************************************************************************************************
202 template< typename T // Type of the operand
203  , typename OP // Type of the custom operation
204  , typename > // Restricting condition
205 struct TotalReduceTraitEval2
206 {
207  public:
208  //**********************************************************************************************
209  using Type = ElementType_t<T>;
210  //**********************************************************************************************
211 };
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
221 template< typename T // Type of the operand
222  , typename OP // Type of the custom operation
223  , size_t RF // Reduction flag
224  , typename > // Restricting condition
225 struct PartialReduceTraitEval1
226 {
227  public:
228  //**********************************************************************************************
229  using Type = typename PartialReduceTraitEval2<T,OP,RF>::Type;
230  //**********************************************************************************************
231 };
233 //*************************************************************************************************
234 
235 
236 //*************************************************************************************************
241 template< typename T // Type of the operand
242  , typename OP // Type of the custom operation
243  , size_t RF // Reduction flag
244  , typename > // Restricting condition
245 struct PartialReduceTraitEval2
246 {
247  public:
248  //**********************************************************************************************
249  using Type = INVALID_TYPE;
250  //**********************************************************************************************
251 };
253 //*************************************************************************************************
254 
255 } // namespace blaze
256 
257 #endif
Header file for auxiliary alias declarations.
Header file for basic type definitions.
Header file for the Decay type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.The ReduceTrait_t alias declaration pr...
Definition: ReduceTrait.h:174
Utility type for generic codes.
Base template for the ReduceTrait class.
Definition: ReduceTrait.h:146