Объясните код

_amper

template <std::size_t M, std::size_t N, typename TupleSum, 
    typename Tuple, std::size_t I, std::size_t... Inds>
struct TupleSumTo
  {
      static void Sum(TupleSum& tSum, Tuple& t)
        {
            TupleSumTo<M, N - 1, TupleSum, Tuple, Inds...>::Sum(tSum, t);
            //std::get<M - N>(tObjs)(std::get<M - N>(tSum), std::get<I>(t));
            std::get<M - N>(tSum) += std::get<I>(t);
        }
  };
 
template <std::size_t M, typename TupleSum, typename Tuple, std::size_t I>
struct TupleSumTo<M, 1, TupleSum, Tuple, I>
{
    //static void Sum(TupleSum& tSum, Tuple& t, TupleObjs& tObjs)
    static void Sum(TupleSum& tSum, Tuple& t)
    {
        //std::get<M-1>(tObjs)(std::get<M-1>(tSum), std::get<I>(t));
        std::get<M-1>(tSum) += std::get<I>(t);
    }
};
template <int... Inds, typename... TypesSum, typename... Types>
decltype(auto) SumTo(tuple<TypesSum...>& tSum, tuple<Types...>& t)
{
    TupleSumTo<sizeof...(Inds), sizeof...(Inds), decltype(tSum), decltype(t), Inds...>::Sum(tSum, t);
    return tSum;
}
1 ответ

_amper

Read about tuple<> type.