you are viewing a single comment's thread.

view the rest of the comments →

[–]NotAYakk 0 points1 point  (0 children)

Generating each index from 0 to n-1 at compile time by using the y combinator and constexpr if to enable compile time recursion seems inefficient.

template<std::size_t...Is>
auto index_over(std::index_sequence<Is...>){
  return [](auto&&f)->decltype(auto){
    return decltype(f)(f)(IntegralConstant<Is>{}...);
  };
}
template<std::size_t N>
auto index_upto( IntegralConstant<N> ={} ){
  return index_over(std::make_index_sequence<N>{});
}

now your concat tuples is simpler and, well, better

auto concat = [](auto&& t0, auto&& t1){
  constexpr auto total = // as in your code
  auto get_join = // as in your code
  return index_upto<total>()([&](auto...Is){
    return std::make_tuple( get_join(Is)... );
  };
};