variadic templates for c++
Generic functions and classes accepting a variable number of type arguments have proven to be a very useful, but missing, feature of C++. Numerous foundational libraries rely on clever template and preprocessor tricks to emulate such variadic templates. By several measures these emulations are inadequate. This paper describes how C++ can be extended with variadic templates, significantly improving existing implementations of widely used C++ libraries in terms of code size, quality of error diagnostics, compilation speed, and generality. Furthermore, variadic templates enable new applications, such as type-safe implementations of functions like printf, and improved support for generic mixin classes. We have implemented variadic templates as an extension of a production quality C++ compiler.
c++ templates template metaprogramming parametric polymorphism variadic arguments