Blaze  3.6
HasMember.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_TYPETRAITS_HASMEMBER_H_
36 #define _BLAZE_UTIL_TYPETRAITS_HASMEMBER_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/EmptyType.h>
45 #include <blaze/util/mpl/If.h>
47 
48 
49 
50 
51 //=================================================================================================
52 //
53 // MACRO DEFINITIONS
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
99 #define BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
100  \
101 template < typename TYPE1230 > \
102 class TYPE_TRAIT_NAME##HELPER \
103 { \
104  private: \
105  template< typename U, U > struct Check; \
106  \
107  struct Fallback { int MEMBER_NAME; }; \
108  \
109  struct Derived \
110  : blaze::If< blaze::IsBuiltin_v<TYPE1230>, blaze::EmptyType, TYPE1230 >::Type \
111  , Fallback \
112  {}; \
113  \
114  template < typename U > \
115  static blaze::FalseType test( Check<int Fallback::*, &U::MEMBER_NAME>* ); \
116  \
117  template < typename U > \
118  static blaze::TrueType test( ... ); \
119  \
120  public: \
121  using Type = decltype( test<Derived>( nullptr ) ); \
122 }; \
123  \
124 template< typename TYPE1230 > \
125 struct TYPE_TRAIT_NAME \
126  : public TYPE_TRAIT_NAME##HELPER<TYPE1230>::Type \
127 {}; \
128  \
129 template< typename TYPE1230 > \
130 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<TYPE1230>::value
131 //*************************************************************************************************
132 
133 
134 //*************************************************************************************************
177 #define BLAZE_CREATE_HAS_TYPE_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
178  \
179 template < typename TYPE1231 > \
180 struct TYPE_TRAIT_NAME##HELPER \
181 { \
182  private: \
183  struct Fallback { using MEMBER_NAME = int; }; \
184  \
185  struct Derived \
186  : blaze::If< blaze::IsBuiltin_v<TYPE1231>, blaze::EmptyType, TYPE1231 >::Type \
187  , Fallback \
188  {}; \
189  \
190  template < class U > \
191  static blaze::FalseType test( typename U::MEMBER_NAME* ); \
192  \
193  template < typename U > \
194  static blaze::TrueType test( U* ); \
195  \
196  public: \
197  using Type = decltype( test<Derived>( nullptr ) ); \
198 }; \
199  \
200 template< typename TYPE1231 > \
201 struct TYPE_TRAIT_NAME \
202  : public TYPE_TRAIT_NAME##HELPER<TYPE1231>::Type \
203 {}; \
204  \
205 template< typename TYPE1231 > \
206 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<TYPE1231>::value
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
253 #define BLAZE_CREATE_HAS_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
254  \
255 template< typename Type1232 > \
256 struct TYPE_TRAIT_NAME##HELPER \
257 { \
258  private: \
259  BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( LOCAL_TYPE_TRAIT_1, MEMBER_NAME ); \
260  BLAZE_CREATE_HAS_TYPE_MEMBER_TYPE_TRAIT( LOCAL_TYPE_TRAIT_2, MEMBER_NAME ); \
261  \
262  public: \
263  static constexpr bool value = ( LOCAL_TYPE_TRAIT_1<Type1232>::value || \
264  LOCAL_TYPE_TRAIT_2<Type1232>::value ); \
265 }; \
266  \
267 template< typename Type1232 > \
268 struct TYPE_TRAIT_NAME \
269  : public blaze::BoolConstant< TYPE_TRAIT_NAME##HELPER<Type1232>::value > \
270 {}; \
271  \
272 template< typename Type1232 > \
273 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<Type1232>::value
274 //*************************************************************************************************
275 
276 #endif
Header file for the If class template.
Header file for the IsBuiltin type trait.
Header file for the IntegralConstant class template.
Header file for the empty type.