I found several questions & answers on SO dealing with detecting at compile time (via SFINAE) whether a given class has a member of certain name, type, or signature. How
Following may help: (https://ideone.com/nDlFUE)
#include
#define DEFINE_HAS_SIGNATURE(traitsName, funcName, signature) \
template \
class traitsName \
{ \
private: \
template struct helper; \
template \
static std::uint8_t check(helper*); \
template static std::uint16_t check(...); \
public: \
static \
constexpr bool value = sizeof(check(0)) == sizeof(std::uint8_t); \
}
Then define a traits:
DEFINE_HAS_SIGNATURE(has_foo, T::foo, void (*)(void));