Variadic Templates

Variadic templates allow a C++ template to accept an arbitrary number of "extra" template arguments. When used with class templates, we can write templates like tuple (a generalized pair), or arbitrary-level compile-time vectors for template metaprogramming. Variadic templates also work in conjunction with function templates, so that function templates can take an arbitrary number of function arguments. In this sense, variadic templates provide the same capabilities as C's variadic functions, but in a type-safe manner. For instance, one can implement a simple, type-safe printf with the following code:

More information is available at


Delivery Date



Modifications Required

None: variadic-templates (last edited 2008-01-10 19:39:00 by localhost)