From 187d7a693f85c0c90d32e38250dfea14039a1b1d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Nov 2022 14:26:59 +0100 Subject: entity: add some metaprogramming crap --- src/entity.hpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src') diff --git a/src/entity.hpp b/src/entity.hpp index 31a13632..10f2a6e4 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -158,6 +158,54 @@ constexpr CORRADE_ALWAYS_INLINE bool find_in_tuple(F&& fun, Tuple&& tuple) return false; } +template class F, typename Acc, typename T, typename... Fs> +struct reduce0_; + +template class F, typename Acc, template class T, typename... Fs> +struct reduce0_, Fs...> { + using type = Acc; +}; + +template class F, typename Acc, template class X, typename T, typename... Ts, typename... Fs> +struct reduce0_, Fs...> { + using type = typename reduce0_< F, F, X, Fs... >::type; +}; + +template class F, typename XC, typename... Fs> +struct reduce_; + +template class F, template class X, typename T1, typename... Ts, typename... Fs> +struct reduce_, Fs...> { + using type = typename reduce0_< F, T1, X, Fs... >::type; +}; + +template class F, typename T, typename... Fs> +using reduce = typename reduce_::type; + +template struct parameter_pack; + +template typename C, typename... Args2> +struct lift_; + +template class C, template class T, typename... Args, typename... CArgs> +struct lift_, C, CArgs...> { + using type = C; +}; + +template class C, typename... CArgs> +using lift = typename lift_::type; + +template class F, template class C, typename T, typename... Us> +struct map_; + +template class F, template class C, template class X, typename... Ts, typename... Us> +struct map_, Us...> { + using type = C...>; +}; + +template class F, typename X, typename... Us> +using map = typename map_::type; + } // namespace detail template -- cgit v1.2.3