June 2017
Intermediate to advanced
532 pages
12h 59m
English
Let's implement a function that takes arbitrarily many parameters and returns their sum:
template <typename ... Ts> auto sum(Ts ... ts);
template <typename ... Ts> auto sum(Ts ... ts) { return (ts + ...); }
int the_sum {sum(1, 2, 3, 4, 5)}; // Value: 15
Read now
Unlock full access