blob: 6a0206fc42cc552b84a494a2ca2262234d6f062c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma once
#include "compat/meta.hpp"
#include <type_traits>
namespace mixins::traits_detail {
using namespace meta;
template<typename... xs> using tuple = tuple_<xs...>;
template<typename t>
struct mixin_traits {
// implement this!
using depends = tuple<>;
// unconditional but at instantiation time
static_assert(sizeof(t) < sizeof(char),
"must specialize mixin_traits");
};
template<typename klass, typename...> struct check_depends_;
template<typename klass>
struct check_depends_<klass> : std::true_type
{
};
template<typename klass, typename x, typename... xs>
struct check_depends_<klass, x, xs...> :
std::bool_constant<
std::is_base_of_v<x, klass> &&
lift<check_depends_, cons<klass, typename mixin_traits<x>::depends>>::value &&
check_depends_<klass, xs...>::value
>
{
};
template<typename klass, typename... xs>
struct impl
{
static constexpr bool class_must_inherit_dependent_mixins =
lift<check_depends_, tuple<klass, xs...>>::value;
static_assert(class_must_inherit_dependent_mixins);
};
} // ns mixins::traits_detail
|