
on Thu Apr 05 2012, Andrzej Krzemienski <akrzemi1-AT-gmail.com> wrote:
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.
For the end users of meta-programming library (at least those interested in type transformations), I believe that alias templates offer a significant improvement to the interface: http://akrzemi1.wordpress.com/2012/03/19/meta-functions-in-c11/
Yeah... I started doing a bunch of that, but I am not yet convinced it's an overall improvement. One thing you emphatically *don't* get with that formulation is lazy evaluation. remove_pointer<int> is valid until you instantiate it but RemovePointer<int> is not, and the former is often quite useful. Also, you can't use metafunction forwarding—which also eliminates vast amounts of typing—with RemovePointer. Also, you end up needing to define more names than you otherwise would (e.g. both remove_pointer and RemovePointer). My standard approach when doing this has been to name them remove_pointer_ and remove_pointer, so at least they have an obvious and mechanical relationship. -- Dave Abrahams BoostPro Computing http://www.boostpro.com