Blaze 3.9
MapTrait.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_TRAITS_MAPTRAIT_H_
36#define _BLAZE_MATH_TRAITS_MAPTRAIT_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/GroupTag.h>
46
47
48namespace blaze {
49
50//=================================================================================================
51//
52// CLASS DEFINITION
53//
54//=================================================================================================
55
56//*************************************************************************************************
58template< typename... > struct MapTrait;
59template< typename, typename, typename = void > struct UnaryMapTraitEval1;
60template< typename, typename, typename = void > struct UnaryMapTraitEval2;
61template< typename, typename, typename = void > struct UnaryMapTraitEval3;
62template< typename, typename, typename, typename = void > struct BinaryMapTraitEval1;
63template< typename, typename, typename, typename = void > struct BinaryMapTraitEval2;
64template< typename, typename, typename, typename = void > struct BinaryMapTraitEval3;
66//*************************************************************************************************
67
68
69//*************************************************************************************************
71template< typename T, typename OP >
72auto evalMapTrait( const volatile T&, OP ) -> UnaryMapTraitEval1<T,OP>;
73
74template< typename T1, typename T2, typename OP >
75auto evalMapTrait( const volatile T1&, const volatile T2&, OP ) -> BinaryMapTraitEval1<T1,T2,OP>;
77//*************************************************************************************************
78
79
80//*************************************************************************************************
110template< typename... Args > // Types of the map template paramters
112 : public decltype( evalMapTrait( std::declval<Args&>()... ) )
113{};
114//*************************************************************************************************
115
116
117//*************************************************************************************************
130template< typename... Args > // Types of the map template paramters
131using MapTrait_t = typename MapTrait<Args...>::Type;
132//*************************************************************************************************
133
134
135//*************************************************************************************************
140template< typename T // Type of the operand
141 , typename OP // Type of the custom operation
142 , typename > // Restricting condition
143struct UnaryMapTraitEval1
144 : public UnaryMapTraitEval2<T,OP>
145{};
147//*************************************************************************************************
148
149
150//*************************************************************************************************
155template< size_t ID, typename OP >
156struct UnaryMapTraitEval1<GroupTag<ID>,OP,void>
157{
158 public:
159 //**********************************************************************************************
160 using Type = GroupTag<ID>;
161 //**********************************************************************************************
162};
164//*************************************************************************************************
165
166
167//*************************************************************************************************
172template< typename T // Type of the operand
173 , typename OP // Type of the custom operation
174 , typename > // Restricting condition
175struct UnaryMapTraitEval2
176 : public UnaryMapTraitEval3<T,OP>
177{};
179//*************************************************************************************************
180
181
182//*************************************************************************************************
187template< typename T // Type of the operand
188 , typename OP // Type of the custom operation
189 , typename > // Restricting condition
190struct UnaryMapTraitEval3
191{};
193//*************************************************************************************************
194
195
196//*************************************************************************************************
201template< typename T // Type of the operand
202 , typename OP > // Type of the custom operation
203struct UnaryMapTraitEval3< T, OP
204 , Void_t< decltype( std::declval<OP>()( std::declval<T>() ) ) > >
205{
206 public:
207 //**********************************************************************************************
208 using Type = RemoveCVRef_t< decltype( std::declval<OP>()( std::declval<T>() ) ) >;
209 //**********************************************************************************************
210};
212//*************************************************************************************************
213
214
215//*************************************************************************************************
220template< typename T1 // Type of the left-hand side operand
221 , typename T2 // Type of the right-hand side operand
222 , typename OP // Type of the custom operation
223 , typename > // Restricting condition
224struct BinaryMapTraitEval1
225 : public BinaryMapTraitEval2<T1,T2,OP>
226{};
228//*************************************************************************************************
229
230
231//*************************************************************************************************
236template< size_t ID, typename OP >
237struct BinaryMapTraitEval1<GroupTag<ID>,GroupTag<ID>,OP,void>
238{
239 public:
240 //**********************************************************************************************
241 using Type = GroupTag<ID>;
242 //**********************************************************************************************
243};
245//*************************************************************************************************
246
247
248//*************************************************************************************************
253template< typename T1 // Type of the left-hand side operand
254 , typename T2 // Type of the right-hand side operand
255 , typename OP // Type of the custom operation
256 , typename > // Restricting condition
257struct BinaryMapTraitEval2
258 : public BinaryMapTraitEval3<T1,T2,OP>
259{};
261//*************************************************************************************************
262
263
264//*************************************************************************************************
269template< typename T1 // Type of the left-hand side operand
270 , typename T2 // Type of the right-hand side operand
271 , typename OP // Type of the custom operation
272 , typename > // Restricting condition
273struct BinaryMapTraitEval3
274{};
276//*************************************************************************************************
277
278
279//*************************************************************************************************
284template< typename T1 // Type of the left-hand side operand
285 , typename T2 // Type of the right-hand side operand
286 , typename OP > // Type of the custom operation
287struct BinaryMapTraitEval3< T1, T2, OP
288 , Void_t< decltype( std::declval<OP>()( std::declval<T1>(), std::declval<T2>() ) ) > >
289{
290 public:
291 //**********************************************************************************************
292 using Type = RemoveCVRef_t< decltype( std::declval<OP>()( std::declval<T1>(), std::declval<T2>() ) ) >;
293 //**********************************************************************************************
294};
296//*************************************************************************************************
297
298} // namespace blaze
299
300#endif
Header file for the GroupTag class template.
Header file for the RemoveCVRef type trait.
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.
Definition: MapTrait.h:131
void Void_t
Compile time type check.
Definition: Void.h:64
Base template for the MapTrait class.
Definition: MapTrait.h:113