What is variadic template, and how do you process a parameter pack?
Last updated
A variadic template takes any number of template arguments through a parameter pack (
typename... Args), expanded withargs...and counted withsizeof....Process a pack by recursion (handle the head, recurse on the tail, stop at a base-case overload) or with C++17 fold expressions like
(... + args).Packs can also be expanded into another call, an initializer list, or
std::forwardfor perfect forwarding.