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>
44 #include <blaze/util/FalseType.h>
46 #include <blaze/util/mpl/If.h>
47 #include <blaze/util/TrueType.h>
49 
50 
51 
52 
53 //=================================================================================================
54 //
55 // MACRO DEFINITIONS
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
101 #define BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
102  \
103 template < typename TYPE1230 > \
104 class TYPE_TRAIT_NAME##HELPER \
105 { \
106  private: \
107  template< typename U, U > struct Check; \
108  \
109  struct Fallback { int MEMBER_NAME; }; \
110  \
111  struct Derived \
112  : blaze::If< blaze::IsBuiltin_v<TYPE1230>, blaze::EmptyType, TYPE1230 >::Type \
113  , Fallback \
114  {}; \
115  \
116  template < typename U > \
117  static blaze::FalseType test( Check<int Fallback::*, &U::MEMBER_NAME>* ); \
118  \
119  template < typename U > \
120  static blaze::TrueType test( ... ); \
121  \
122  public: \
123  using Type = decltype( test<Derived>( nullptr ) ); \
124 }; \
125  \
126 template< typename TYPE1230 > \
127 struct TYPE_TRAIT_NAME \
128  : public TYPE_TRAIT_NAME##HELPER<TYPE1230>::Type \
129 {}; \
130  \
131 template< typename TYPE1230 > \
132 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<TYPE1230>::value
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
179 #define BLAZE_CREATE_HAS_TYPE_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
180  \
181 template < typename TYPE1231 > \
182 struct TYPE_TRAIT_NAME##HELPER \
183 { \
184  private: \
185  struct Fallback { using MEMBER_NAME = int; }; \
186  \
187  struct Derived \
188  : blaze::If< blaze::IsBuiltin_v<TYPE1231>, blaze::EmptyType, TYPE1231 >::Type \
189  , Fallback \
190  {}; \
191  \
192  template < class U > \
193  static blaze::FalseType test( typename U::MEMBER_NAME* ); \
194  \
195  template < typename U > \
196  static blaze::TrueType test( U* ); \
197  \
198  public: \
199  using Type = decltype( test<Derived>( nullptr ) ); \
200 }; \
201  \
202 template< typename TYPE1231 > \
203 struct TYPE_TRAIT_NAME \
204  : public TYPE_TRAIT_NAME##HELPER<TYPE1231>::Type \
205 {}; \
206  \
207 template< typename TYPE1231 > \
208 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<TYPE1231>::value
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
255 #define BLAZE_CREATE_HAS_MEMBER_TYPE_TRAIT( TYPE_TRAIT_NAME, MEMBER_NAME ) \
256  \
257 template< typename Type1232 > \
258 struct TYPE_TRAIT_NAME##HELPER \
259 { \
260  private: \
261  BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( LOCAL_TYPE_TRAIT_1, MEMBER_NAME ); \
262  BLAZE_CREATE_HAS_TYPE_MEMBER_TYPE_TRAIT( LOCAL_TYPE_TRAIT_2, MEMBER_NAME ); \
263  \
264  public: \
265  static constexpr bool value = ( LOCAL_TYPE_TRAIT_1<Type1232>::value || \
266  LOCAL_TYPE_TRAIT_2<Type1232>::value ); \
267 }; \
268  \
269 template< typename Type1232 > \
270 struct TYPE_TRAIT_NAME \
271  : public blaze::BoolConstant< TYPE_TRAIT_NAME##HELPER<Type1232>::value > \
272 {}; \
273  \
274 template< typename Type1232 > \
275 static constexpr bool TYPE_TRAIT_NAME##_v = TYPE_TRAIT_NAME<Type1232>::value
276 //*************************************************************************************************
277 
278 #endif
Header file for the FalseType type/value trait base class.
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.
Header file for the TrueType type/value trait base class.