Skip to content

Instantly share code, notes, and snippets.

@revsic
Created February 5, 2019 11:50
Show Gist options
  • Save revsic/e1e54035d9eba80f17db394bdfba2ea3 to your computer and use it in GitHub Desktop.
Save revsic/e1e54035d9eba80f17db394bdfba2ea3 to your computer and use it in GitHub Desktop.
#include <type_traits>
#define REQUIRE(method, ...) \
template <typename Cont, typename = void> \
struct require_##method : std::false_type {}; \
template <typename Cont> \
struct require_##method< \
Cont, \
std::void_t<decltype(std::declval<Cont>().method(__VA_ARGS__))>> \
: std::true_type {}; \
template <typename T> \
constexpr bool require_##method##_v = valid_##method<T>::value;
#define VAL(T) std::declval<T>()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment