#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace ss { //////////////// // tup merge/cat //////////////// template struct tup_cat; template struct tup_cat, std::tuple> { using type = std::tuple; }; template struct tup_cat> { using type = std::tuple; }; template using tup_cat_t = typename tup_cat::type; //////////////// // tup first/head //////////////// template struct left_of_impl; template struct left_of_impl { static_assert(N < 128, "recursion limit reached"); static_assert(N != 0, "cannot take the whole tuple"); using type = tup_cat_t::type>; }; template struct left_of_impl<0, T, Ts...> { using type = std::tuple; }; template using left_of_t = typename left_of_impl::type; template using first_t = typename left_of_impl::type; template using head_t = typename left_of_impl<0, Ts...>::type; //////////////// // tup tail/last //////////////// template struct right_of_impl; template struct right_of_impl { using type = typename right_of_impl::type; }; template struct right_of_impl<0, T, Ts...> { using type = std::tuple; }; template using right_of_t = typename right_of_impl::type; template using tail_t = typename right_of_impl<1, Ts...>::type; template using last_t = typename right_of_impl::type; //////////////// // apply trait //////////////// template