Boost logo

Boost :

Subject: Re: [boost] "Simple C++11 metaprogramming"
From: Eric Niebler (eniebler_at_[hidden])
Date: 2015-08-13 14:44:53


On 7/16/2015 10:35 AM, Robert Ramey wrote:
> On 5/30/15 9:26 AM, Peter Dimov wrote:
>> I've recently made the mistake to reread Eric Niebler's excellent "Tiny
>> Metaprogramming Library" article
>>
>> http://ericniebler.com/2014/11/13/tiny-metaprogramming-library/
>>
>> which of course prompted me to try to experiment with my own tiny
>> metaprogramming library and to see how I'd go about implementing
>> tuple_cat (a challenge Eric gives.)
>>
>> Ordinarily, any such experiments of mine leave no trace once I abandon
>> them and move on,
>
> We need a permanent place for stuff like this.
>
>> but this time I decided to at least write an article
>> about the result, so here it is, with the hope someone might find it
>> useful. :-)
>
>> http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html
>
> This to me is incredible. I worthy successor to Abraham's and
> Gurtovoy's MPL book. Clearly C++/11 is going to turnout to be a major
> game changer with repercussions beyond what we can imagine now.

AFAICT, Peter's code is basically a work-alike of my Meta library [^1]
with one feature added (the ability to treat any template instance as a
typelist), and one feature removed (metafunction classes and their
associated utilities).

I really believe losing metafunction classes is a significant loss --
not so much because template template parameters are so awful (but they
kind of are), but because all the functional composition utilities
(bind, compose, curry, uncurry, on, etc.) are so incredibly useful. And
also because core issue #1430 [^2] makes it impossible to handle
variadic and fixed-arity template aliases uniformly.

Meta's approach -- borrowed from the MPL -- of quoting template template
parameters to turn them into metafunction classes (aka alias classes)
puts the workaround for #1430 in one place so that it can be ignored and
forgotten.

But in the end, Peter's and my thinking is pretty aligned wrt
metaprogramming in C++11 and beyond.

[1]: https://github.com/ericniebler/meta
[2]: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1430

-- 
Eric Niebler
Boost.org
http://www.boost.org

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk