Go to the documentation of this file.    2 #ifndef SPROCKIT_SPROCKIT_PREPROCESSOR_H_     3 #define SPROCKIT_SPROCKIT_PREPROCESSOR_H_     8 #  define spkt_static_assert(...) static_assert(__VA_ARGS__)    17 #include <type_traits>      56 #define SPKT_GENERATE_HAS_MEMBER_TYPE(Type)                                       \    58 namespace sprockit { namespace validation {                                       \    59 template < class T >                                                              \    60 class HasMemberType_##Type                                                        \    63     using Yes = char[2];                                                          \    66     struct Fallback { struct Type { }; };                                         \    67     struct Derived : T, Fallback { };                                             \    69     template < class U >                                                          \    70     static No& test ( typename U::Type* );                                        \    71     template < typename U >                                                       \    72     static Yes& test ( U* );                                                      \    75     static constexpr bool RESULT = sizeof(test<Derived>(nullptr)) == sizeof(Yes); \    78 template < class T >                                                              \    79 struct has_member_type_##Type                                                     \    80 : public std::integral_constant<bool, HasMemberType_##Type<T>::RESULT>            \    85 #  define SPKT_HAS_MEMBER_TYPE_VALIDATION 1   125 #define SPKT_GENERATE_HAS_MEMBER(member)                                          \   127 namespace sprockit { namespace validation {                                       \   128 template < class T >                                                              \   129 class HasMember_##member                                                          \   132     using Yes = char[2];                                                          \   133     using  No = char[1];                                                          \   135     struct Fallback { int member; };                                              \   136     struct Derived : T, Fallback { };                                             \   138     template < class U >                                                          \   139     static No& test ( decltype(U::member)* );                                     \   140     template < typename U >                                                       \   141     static Yes& test ( U* );                                                      \   144     static constexpr bool RESULT = sizeof(test<Derived>(nullptr)) == sizeof(Yes); \   147 template < class T >                                                              \   148 struct has_member_##member                                                        \   149 : public std::integral_constant<bool, HasMember_##member<T>::RESULT>              \   153 #  define SPKT_HAS_MEMBER_VALIDATION 1   161 #else // No validation when CPP11 is not available   165 #endif // SPKT_HAVE_CPP11