#ifndef TMP_TREEALGO_H #define TMP_TREEALGO_H #include "packalgo.h" #include "tree.h" #include "utility.h" namespace tmp { /** * TreeTransform */ template class> struct TreeTransformImpl; template class F> struct TreeTransformImpl, F> { using type = Tree, typename TreeTransformImpl::type...>; }; template class F> struct TreeTransformImpl, F> { using type = Tree<>; }; template class F> using TreeTransform = typename TreeTransformImpl::type; /** * TreeAccumulate */ template class, typename> struct TreeAccumulateImpl; template class F, typename A> struct TreeAccumulateImpl, F, A> { using type = F::type...>; }; template class F, typename A> struct TreeAccumulateImpl, F, A> { using type = F; }; template class F, typename A> struct TreeAccumulateImpl, F, A> { using type = A; }; template class F, typename A> using TreeAccumulate = typename TreeAccumulateImpl::type; /** * TreeNLRAccumulate */ template class F, typename A> using TreeNLRAccumulate = Accumulate, GetType>, F, A>; /** * TreeHeight */ template struct TreeHeightImpl { template using CalcHeight = std::integral_constant>; using CalcHeightDefault = std::integral_constant; static constexpr Depth value = TreeAccumulate::value; }; template constexpr Depth TreeHeight = TreeHeightImpl::value; /** * TreeAllRTLPaths */ namespace detail { template struct PackPushFronter { template using Do = PackPushFront; }; } template struct TreeAllRTLPathsImpl; template struct TreeAllRTLPathsImpl> { using type = PackCat::type, Bind2nd::template F1>...>; }; template struct TreeAllRTLPathsImpl> { using type = Pack>; }; template<> struct TreeAllRTLPathsImpl> { using type = Pack<>; }; template using TreeAllRTLPaths = typename TreeAllRTLPathsImpl::type; } #endif