Lets say I have
struct foo {
void ham() {}
void ham() const {}
};
struct bar {
void ham() {}
};
Assuming I have a templated fu
With
#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); \
}
DEFINE_HAS_SIGNATURE(has_ham_const, T::ham, void (T::*)() const);
And then
static_assert(has_ham_const::value, "unexpected");
static_assert(!has_ham_const::value, "unexpected");
Demo