Subject: Re: [boost] C++11 Metaprogramming
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-04-01 09:24:57
On 04/01/2012 04:12 AM, Dave Abrahams wrote:
> Hi All,
> I am on the C++Now 2012 schedule giving a talk on metaprogramming in
> C++11, which is really just supposed to be an overview of the state of
> the art. I am just at the beginnings of my research for this
> presentation, having learned a few things and done a few experiments,
> and it seemed to me foolish not to ask the Boost community for its
> insights. I'm sure y'all have come up with many neat tricks and
> techniques. If you'd care to share them here, that would be much
From a pure meta-programming perspective, I guess the only real
addition is variadic templates.
However, there is the problem that they're fairly limited and that one
may not expand them as the arguments of a non-variadic template.
Since I need to integrate with other libraries and tools, I therefore
use them very rarely.
One very useful use of variadic templates however is with function
templates. They allow to make a function template with 0 arguments,
which wasn't possible in C++03. This can be used to delay instantiation
of the function body which can be necessary if name resolution needs to
This is also possible with the new function template default arguments.
A new possibility with C++11 is the use of SFINAE to test arbitrary
expressions. I have not found this to be particularly useful in
Detecting nested types is often good enough.
decltype is very useful. I use it in some meta-programming contexts to
select a type when I need best-match selection:
The only thing we could do before C++11 was return a type with a unique
size, then associate that size to a type.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk