diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-22 11:52:33 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-24 00:43:05 +0200 |
commit | f4924871e2459714680e25fc3de268d80d6f3778 (patch) | |
tree | 4f64452fff83b9c51d49574c4578e40d3c90375f /main-window/mixin-traits.hpp | |
parent | a926817c81a80842a52191a7358e9bb64ab3cf80 (diff) |
main-window: further work
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 |