May 2017
Intermediate to advanced
590 pages
17h 18m
English
The examples in this recipe are based on the variadic function template add() that we wrote in the previous recipe, Writing a function template with a variable number of arguments. That implementation is a left-folding operation. For simplicity, we present the function again:
template <typename T> T add(T value) { return value; } template <typename T, typename... Ts> T add(T head, Ts... rest) { return head + add(rest...); }
Read now
Unlock full access