From a924f54ef87764bd9bc257babd3a02aafcc90cbb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Jul 2018 08:59:16 +0200 Subject: compat/meta: fixes --- compat/meta.hpp | 71 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'compat') diff --git a/compat/meta.hpp b/compat/meta.hpp index a116cebc..4dec8bbb 100644 --- a/compat/meta.hpp +++ b/compat/meta.hpp @@ -7,20 +7,13 @@ * copyright notice and this permission notice appear in all copies. */ -#define OTR_META_INST_FAIL(x) \ - static_assert(sizeof...(x) == ~0ul); \ - static_assert(sizeof...(x) == 0u) - namespace meta::detail { template struct tuple; template - struct reverse_ - { - OTR_META_INST_FAIL(xs); - }; + struct reverse_; template class x, typename... ys> struct reverse_, x> @@ -34,11 +27,7 @@ namespace meta::detail { using type = x; }; - template class inst, typename... xs> - struct lift_ - { - OTR_META_INST_FAIL(xs); - }; + template class, typename, typename...> struct lift_; template class to, template class from, typename... xs> struct lift_> @@ -46,17 +35,59 @@ namespace meta::detail { using type = to; }; - template struct cons_; + template struct append_helper; + + template struct cons_; template class t, typename x, typename... xs> - struct cons_, x> + struct cons_> { using type = t; }; + template struct append2; + + template class t, typename... xs> + struct append2> + { + template struct append1; + + template class u, typename... ys> + struct append1> + { + using type = t; + }; + }; + + template struct list__; + + template + struct list__ + { + template struct list1; + + template class t, typename... xs> + struct list1> + { + using type = t; + }; + + using type = typename list1::type; + }; + + template + struct append_ + { + using t1 = append2; + using type = typename t1::template append1::type; + }; + } // ns meta::detail namespace meta { + template + using tuple_ = detail::tuple; + template using reverse = typename detail::reverse_, detail::tuple<>>::type; @@ -76,8 +107,14 @@ namespace meta { template using last = lift>; - template - using cons = detail::cons_; + template + using cons = typename detail::cons_::type; + + template + using append = typename detail::append_; + + template + using list_ = typename detail::list__; } // ns meta -- cgit v1.2.3