Template metaprogramming

Template metaprogramming allows programmer to perform some computations during compile time. It can influence only program architecture (make it better) and it can make the program much faster.

Sometimes templates can be used in a way they are not supposed to be used. Funny/scary example of such a case is program for generating lyrics to the song "99 Bottles of Beer".

Compare it with basic C++ example in hacking style by Tim Robinson.

See resources below:

Advanced templates

Variadic templates

Type traits

Used to declare requirements for template arguments.

Tag dispatching

Used to select specialized functions depending on argument types.

Metaprogramming - basics

Metaprogramming - advanced techniques

Books

Videos

See also

Share

follow