Boost logo

Boost :

Subject: Re: [boost] C++11 Metaprogramming
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2012-04-03 12:57:35

On Apr 3, 2012, at 12:23 PM, Dave Abrahams wrote:

> on Sun Apr 01 2012, Howard Hinnant <> wrote:
>> On Mar 31, 2012, at 10:12 PM, 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
>>> appreciated.
>> The fact that noexcept(expression) is a compile-time bool is like
>> unwrapping a shiny new toy on your birthday. :-)
> That's lovely, but... exactly how does noexcept play into the
> metaprogramming picture?

For example, I used it to create an is_nothrow_swappable<A> trait ( so that I could write:

struct B
    A a;

void swap(B& x, B& y) noexcept(__is_nothrow_swappable<A>::value)
    swap(x.a, y.a);

instead of:

using std::swap;
void swap(B& x, B& y) noexcept(
    swap(x.a, y.a);

The latter gets very tedious when B has several members and/or bases.


Boost list run by bdawes at, gregod at, cpdaniel at, john at