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>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
57 template< typename... > struct MapTrait;
58 template< typename, typename, typename = void > struct UnaryMapTraitEval1;
59 template< typename, typename, typename = void > struct UnaryMapTraitEval2;
60 template< typename, typename, typename, typename = void > struct BinaryMapTraitEval1;
61 template< typename, typename, typename, typename = void > struct BinaryMapTraitEval2;
63 //*************************************************************************************************
64 
65 
66 //*************************************************************************************************
68 template< typename T, typename OP >
69 auto evalMapTrait( T&, OP )
70  -> typename UnaryMapTraitEval1<T,OP>::Type;
71 
72 template< typename T, typename OP >
73 auto evalMapTrait( const T&, OP )
74  -> typename MapTrait<T,OP>::Type;
75 
76 template< typename T, typename OP >
77 auto evalMapTrait( const volatile T&, OP )
78  -> typename MapTrait<T,OP>::Type;
79 
80 template< typename T1, typename T2, typename OP >
81 auto evalMapTrait( T1&, T2&, OP )
82  -> typename BinaryMapTraitEval1<T1,T2,OP>::Type;
83 
84 template< typename T1, typename T2, typename OP >
85 auto evalMapTrait( const T1&, const T2&, OP )
86  -> typename MapTrait<T1,T2,OP>::Type;
87 
88 template< typename T1, typename T2, typename OP >
89 auto evalMapTrait( const T1&, const volatile T2&, OP )
90  -> typename MapTrait<T1,T2,OP>::Type;
91 
92 template< typename T1, typename T2, typename OP >
93 auto evalMapTrait( const volatile T1&, const T2&, OP )
94  -> typename MapTrait<T1,T2,OP>::Type;
95 
96 template< typename T1, typename T2, typename OP >
97 auto evalMapTrait( const volatile T1&, const volatile T2&, OP )
98  -> typename MapTrait<T1,T2,OP>::Type;
100 //*************************************************************************************************
101 
102 
103 //*************************************************************************************************
133 template< typename... Args > // Types of the map template paramters
134 struct MapTrait
135 {
136  public:
137  //**********************************************************************************************
139  using Type = decltype( evalMapTrait( std::declval<Args&>()... ) );
141  //**********************************************************************************************
142 };
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
159 template< typename... Args > // Types of the map template paramters
160 using MapTrait_t = typename MapTrait<Args...>::Type;
161 //*************************************************************************************************
162 
163 
164 //*************************************************************************************************
169 template< typename T // Type of the operand
170  , typename OP // Type of the custom operation
171  , typename > // Restricting condition
172 struct UnaryMapTraitEval1
173 {
174  public:
175  //**********************************************************************************************
176  using Type = typename UnaryMapTraitEval2<T,OP>::Type;
177  //**********************************************************************************************
178 };
180 //*************************************************************************************************
181 
182 
183 //*************************************************************************************************
188 template< typename T // Type of the operand
189  , typename OP // Type of the custom operation
190  , typename > // Restricting condition
191 struct UnaryMapTraitEval2
192 {
193  public:
194  //**********************************************************************************************
195  using Type = Decay_t< decltype( std::declval<OP>()( std::declval<T>() ) ) >;
196  //**********************************************************************************************
197 };
199 //*************************************************************************************************
200 
201 
202 //*************************************************************************************************
207 template< typename T1 // Type of the left-hand side operand
208  , typename T2 // Type of the right-hand side operand
209  , typename OP // Type of the custom operation
210  , typename > // Restricting condition
211 struct BinaryMapTraitEval1
212 {
213  public:
214  //**********************************************************************************************
215  using Type = typename BinaryMapTraitEval2<T1,T2,OP>::Type;
216  //**********************************************************************************************
217 };
219 //*************************************************************************************************
220 
221 
222 //*************************************************************************************************
227 template< typename T1 // Type of the left-hand side operand
228  , typename T2 // Type of the right-hand side operand
229  , typename OP // Type of the custom operation
230  , typename > // Restricting condition
231 struct BinaryMapTraitEval2
232 {
233  public:
234  //**********************************************************************************************
235  using Type = Decay_t< decltype( std::declval<OP>()( std::declval<T1>(), std::declval<T2>() ) ) >;
236  //**********************************************************************************************
237 };
239 //*************************************************************************************************
240 
241 } // namespace blaze
242 
243 #endif
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.The MapTrait_t alias declaration provides...
Definition: MapTrait.h:160
Header file for the Decay type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Base template for the MapTrait class.
Definition: MapTrait.h:134