Re: [boost] C++11 Metaprogramming

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/ Regards, &rzej

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/
Maybe you know, maybe you don't, but the alias template style you refer to is used extensively in Origin (http://code.google.com/p/origin/). Actually, so are a number of other techniques discussed in this thread, or variations of them. The code to expand a tuple as function arguments looks very familiar.

on Thu Apr 05 2012, Andrew Sutton <asutton.list-AT-gmail.com> wrote:
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/
Maybe you know, maybe you don't, but the alias template style you refer to is used extensively in Origin (http://code.google.com/p/origin/).
Actually, so are a number of other techniques discussed in this thread, or variations of them. The code to expand a tuple as function arguments looks very familiar.
I'm sure. Are there any other parts of origin you'd recommend I take a look at? -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Actually, so are a number of other techniques discussed in this thread, or variations of them. The code to expand a tuple as function arguments looks very familiar.
I'm sure. Are there any other parts of origin you'd recommend I take a look at?
You might look at the traits library and the concept emulation work. The approach is a little different than what I usually see on the interwebs. The kind of metaprogramming that I usually use is pretty limited to that style. I haven't found the need for anything more general.

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

On 05/04/12 15:58, Dave Abrahams wrote:
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.
For exactly those reasons, I do not find that approach useful. Functional programming in a meta-programming context often involves lambdas or delayed evaluation of some sort.
participants (4)
-
Andrew Sutton
-
Andrzej Krzemienski
-
Dave Abrahams
-
Mathias Gaunard