summaryrefslogtreecommitdiffhomepage
path: root/main-window/mixin-traits.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-22 11:52:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-24 00:43:05 +0200
commitf4924871e2459714680e25fc3de268d80d6f3778 (patch)
tree4f64452fff83b9c51d49574c4578e40d3c90375f /main-window/mixin-traits.cpp
parenta926817c81a80842a52191a7358e9bb64ab3cf80 (diff)
main-window: further work
Diffstat (limited to 'main-window/mixin-traits.cpp')
-rw-r--r--main-window/mixin-traits.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/main-window/mixin-traits.cpp b/main-window/mixin-traits.cpp
index ea8e9bc8..5dc2efd8 100644
--- a/main-window/mixin-traits.cpp
+++ b/main-window/mixin-traits.cpp
@@ -1,22 +1,27 @@
-//#define MIXIN_TRAIT_TESTS
+#define MIXIN_TRAIT_TESTS
#ifdef MIXIN_TRAIT_TESTS
# include "mixin-traits.hpp"
+// the `impl' class provides a cast template through the CRTP pattern.
+// mixins don't do direct inheritance on themselves,
+// that's what mixin_traits::depends is for.
+
namespace mixins::traits_detail {
struct A {};
-struct B : A {};
+struct B {};
struct C {};
+struct D {};
-template<> struct mixin_traits<B>
+template<> struct mixin_traits<A>
{
- using depends = tuple<A>;
+ using depends = tuple<>;
};
-template<> struct mixin_traits<A>
+template<> struct mixin_traits<B>
{
- using depends = tuple<>;
+ using depends = tuple<A>;
};
template<> struct mixin_traits<C>
@@ -24,13 +29,31 @@ template<> struct mixin_traits<C>
using depends = tuple<A>;
};
+template<> struct mixin_traits<D>
+{
+ using depends = tuple<C>;
+};
+
extern void test1();
void test1()
{
- //impl<C> fail1;
- impl<B> ok1;
- impl<A> ok2;
+ struct U : B, A {};
+ struct V : D {};
+ struct W : C, A {};
+ struct Q : virtual W, virtual D {};
+
+#if 0
+ (void)impl<Q, W>(); // W not a mixin
+ (void)impl<V, A>(); // A
+ (void)impl<V, D>(); // D => C => A
+ (void)impl<V, D>(); // D => C => A
+ (void)impl<W, C, B>(); // B
+#else
+ (void)impl<U, B>();
+ (void)impl<W, C>();
+ (void)impl<Q, D, A>();
+#endif
}
} // ns mixins::traits_detail