August 2012
Intermediate to advanced
976 pages
30h 17m
English
Aside from taking its size, the only other thing we can do with a parameter pack is to expand it. When we expand a pack, we also provide a pattern to be used on each expanded element. Expanding a pack separates the pack into its constituent elements, applying the pattern to each element as it does so. We trigger an expansion by putting an ellipsis (. . . ) to the right of the pattern.
For example, our print function contains two expansions:
template <typename T, typename... Args>ostream &print(ostream &os, const T &t, const Args&... rest)// expand Args{ os << t << ", "; return print(os, rest...); // ...
Read now
Unlock full access