An Introduction to C++ Templates
Why Templates?
Generic programming has become a dominant programming paradigm in C++, particularly after
the incorporation of the Standard Template Library (STL) as part of the standard library in 1996.
Templates - the...
More
An Introduction to C++ Templates
Why Templates?
Generic programming has become a dominant programming paradigm in C++, particularly after
the incorporation of the Standard Template Library (STL) as part of the standard library in 1996.
Templates - the language feature that supports generic programming in C++ - was originally
conceived for supporting ‘parameterized types’ (classes parametrized by type information) in
writing container classes.
Templates are a compile time mechanism.
Because of this, there is no runtime overhead
associated with using them.
Also, using templates is completely type safe.
Templates help to
seamlessly integrate all types and thereby let programmers write code for one (generic) type.
So,
it serves as a mechanism for writing high-level reusable code, which is known as ‘generic
programming’.
Like the structured, modular and object oriented programming approaches,
generic programming is another programming approach (and C++ supports all these four
program
Less