opm/material/common/HasMemberGeneratorMacros.hpp File Reference

Go to the source code of this file.

Defines

#define OPM_GENERATE_HAS_MEMBER(MEMBER_NAME,...)
 This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.

Detailed Description

This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization. e.g. if OPM_GENERATE_HAS_MEMBER(foo, int(), int(), int()) has been used, HasMember_foo<T>::value is true (if and only if) t.foo(int(), int(), int()) is a valid expression for an object t of the class T.


Define Documentation

#define OPM_GENERATE_HAS_MEMBER ( MEMBER_NAME,
...   ) 
Value:
template <class T, class T2>                                        \
    struct HasMember_##MEMBER_NAME##_Helper                             \
    {                                                                   \
        static constexpr bool value = false;                            \
    };                                                                  \
                                                                        \
    template <class T>                                                  \
    struct HasMember_##MEMBER_NAME##_Helper<T,                             \
      typename Opm::AlwaysVoid<decltype(std::declval<T>().MEMBER_NAME(__VA_ARGS__))>::type> \
    {                                                                   \
        static constexpr bool value = true;                             \
    };                                                                  \
                                                                        \
    template<typename T>                                                \
    struct HasMember_##MEMBER_NAME                                            \
    {                                                                   \
        static constexpr bool value = HasMember_##MEMBER_NAME##_Helper<T, void>::value; \
    };

This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.

e.g. if OPM_GENERATE_HAS_MEMBER(foo, int(), int(), int()) has been used, HasMember_foo<T>::value is true (if and only if) t.foo(int(), int(), int()) is a valid expression for an object t of the class T.


Generated on 25 Mar 2018 by  doxygen 1.6.1