-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I was working with the approach from this library and I found the following type trait to be useful. It might be worth including in your library if you agree:
template <typename T>
struct is_mixin {
private:
template <template <class> class... Mixins>
static decltype(
static_cast<const mixin<T, Mixins...>>(std::declval<T>()),
std::true_type{})
test(const mixin<T, Mixins...>&);
static std::false_type test(...);
public:
static constexpr bool value =
decltype(is_mixin::test(std::declval<T>()))::value;
};
template <typename T>
inline constexpr bool is_mixin_v = is_mixin<T>::value;Usage:
template <typename Base>
struct A {
CIABATTA_DEFAULT_MIXIN_CTOR(A, Base);
int foo;
};
struct B : ciabatta::mixin<B, A> {};
static_assert(is_mixin_v<B>);
static_assert(!is_mixin_v<A>);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels