diff options
Diffstat (limited to 'main-window/mixin-traits.hpp')
-rw-r--r-- | main-window/mixin-traits.hpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/main-window/mixin-traits.hpp b/main-window/mixin-traits.hpp index 84a64d08..6a0206fc 100644 --- a/main-window/mixin-traits.hpp +++ b/main-window/mixin-traits.hpp @@ -1,7 +1,5 @@ #pragma once -#include "compat/linkage-macros.hpp" -#include "compat/macros.hpp" #include "compat/meta.hpp" #include <type_traits> @@ -9,40 +7,41 @@ namespace mixins::traits_detail { using namespace meta; - template<typename... xs> - using tuple = meta::detail::tuple<xs...>; + + template<typename... xs> using tuple = tuple_<xs...>; template<typename t> struct mixin_traits { - //using depends = tuple<>; + // 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> + struct check_depends_<klass> : std::true_type { - using type = std::bool_constant<true>; }; template<typename klass, typename x, typename... xs> - struct check_depends_<klass, x, 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 + > { - using b1 = std::is_base_of<x, klass>; - using b2 = typename check_depends_<klass, xs...>::type; - - using depends = typename mixin_traits<x>::depends; - using t1 = cons<klass, depends>; - using t2 = lift<check_depends_, t1>; - using b3 = typename t2::type; - - using type = std::bool_constant<b1::value && b2::value && b3::value>; }; - template<typename t> - class impl + template<typename klass, typename... xs> + struct impl { - using t1 = typename lift<check_depends_, cons<t, typename mixin_traits<t>::depends>>::type; - static_assert(t1::value); + 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 |