diff options
Diffstat (limited to 'main-window')
| -rw-r--r-- | main-window/mixin-traits.cpp | 11 | ||||
| -rw-r--r-- | main-window/mixin-traits.hpp | 30 | 
2 files changed, 22 insertions, 19 deletions
| diff --git a/main-window/mixin-traits.cpp b/main-window/mixin-traits.cpp index f914605e..a374eade 100644 --- a/main-window/mixin-traits.cpp +++ b/main-window/mixin-traits.cpp @@ -3,7 +3,7 @@  #ifdef MIXIN_TRAIT_TESTS  #   include "mixin-traits.hpp" -namespace mixins::traits_detail { +//namespace mixins::traits_detail {  struct A {};  struct B : A {}; @@ -16,22 +16,23 @@ template<> struct mixin_traits<B>  template<> struct mixin_traits<A>  { -    using depends = tuple<B>; +    using depends = tuple<>;  };  template<> struct mixin_traits<C>  { -    using depends = tuple<B, A>; +    using depends = tuple<A>;  };  extern void test1();  void test1()  { -    //impl<A> fail1; +    //impl<C> fail1;      impl<B> ok1; +    impl<A> ok2;  } -} // ns mixins::traits_detail +//} // ns mixins::traits_detail  #endif diff --git a/main-window/mixin-traits.hpp b/main-window/mixin-traits.hpp index 5988dc83..07eec98d 100644 --- a/main-window/mixin-traits.hpp +++ b/main-window/mixin-traits.hpp @@ -6,15 +6,15 @@  #include <type_traits> -namespace mixins::traits_detail { +//namespace mixins::traits_detail {      using namespace meta;      template<typename... xs> -    using tuple = meta::detail::tuple<xs...> {} +    using tuple = meta::detail::tuple<xs...>;      template<typename t>      struct mixin_traits { -        using depends = tuple<>; +        //using depends = tuple<>;      };      template<typename klass, typename...> struct check_depends_; @@ -22,20 +22,21 @@ namespace mixins::traits_detail {      template<typename klass>      struct check_depends_<klass>      { -        static constexpr bool recurse() { return true; } +        using type = std::bool_constant<true>;      };      template<typename klass, typename x, typename... xs>      struct check_depends_<klass, x, xs...>      { -        static constexpr bool recurse() -        { -            using depends = typename mixin_traits<x>::depends; - -            return (std::is_base_of_v<x, klass> || std::is_same_v<x, klass>) && -                   check_depends_<klass, xs...>::recurse() && -                   lift<check_depends_, cons<klass, depends>>::recurse(); -        } +        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>;      };  #if 0 @@ -58,6 +59,7 @@ namespace mixins::traits_detail {      template<typename t>      class impl      { -        static_assert(lift<check_depends_, cons<t, typename mixin_traits<t>::depends>>::recurse()); +        using t1 = typename lift<check_depends_, cons<t, typename mixin_traits<t>::depends>>::type; +        static_assert(t1::value);      }; -} // ns mixins::traits_detail +//} // ns mixins::traits_detail | 
