Freestyling on patterns, idioms and semantics…

Icon

vivid hallucinations for bloodthirsty digital vampires

Variadic Metafunctions

An interesting use of variadic template arguments [VTA] comes used with metaprogramming: it results in a metafunction that takes a variable number of arguments.

For those who have never heard about metafuncions I would suggest to read a couple of books,  C++ Modern Design Pattern and the more specific C++ Template Metaprogramming. To make the long story short,  a metafunction is a function that runs at compile time. The technique was discovered by Erwin Unruh  years ago when he created a C++ program that, though not compiling, was able to generate the sequence of prime numbers in form of  compiler error messages.

Read the rest of this entry »

Advertisements

Filed under: C++11, programming

The Cool Factor(y)

With the coming of C++0x our previous C++ codes seem to have become too boilerplate. Among the number of important changes and improvements over the core language, the one I like most is the variadic template argument, a new semantic that enables the variable number of template arguments for both template classes and functions.

In turn, the variadic template arguments [VTA], along with the r-value reference that allows the perfect forwarding, enable users to design very compact patterns with a high level of code re-usability, opening the doors to a new way of writing generic code.

Read the rest of this entry »

Filed under: c++, C++11, programming

Follow me on twitter…