Boost logo

Boost :

Subject: Re: [boost] "Simple C++11 metaprogramming"
From: Bruno Dutra (brunocodutra_at_[hidden])
Date: 2015-06-01 20:31:30


2015-06-01 20:55 GMT-03:00 Peter Dimov <lists_at_[hidden]>:

> You can't just say "we need higher-order metaprogramming to return
> metafunctions from metafunctions" - this is a tautology. This is what
> "higher-order metaprogramming" means. You're basically saying that we need
> higher-order metaprogramming to do higher-order metaprogramming. True but
> trivial.
>

My choice of words might have been unfortunate, I was just trying to draw
attention to the fact that even if argument binding and all those bells and
whistles aren't necessary, metafunctions returning metafunctions alone
would call for metafunction-classes. Still, laziness and SFINAE
friendliness are the properties I deem most fundamental on any
metaprogramming library.

> There obviously do exist occasions that call for higher-order
> metaprogramming. The question is can we get by in 97% of the cases without
> it. Not whether it's useful, but whether it's indispensable. Whether
> there's a room for a "simple" metaprogramming library that doesn't provide
> higher-order constructs and is therefore based on template aliases and not
> on metafunction classes, and whether such a library can be adequately
> useful for real world tasks. (I'm open to the possibility that the answer
> is "no", but I'd like it to be "yes".)
>

I get the point, the question I raise is: "is MPL all that complex in a
C++11 world?"

After long discussions on this list a couple of months ago I decided to
experiment with rewriting MPL from scratch using C++11 as a starting point.
So far I have its "metafunctional" halve, that is, the part deals with
higher order metaprogramming, fairly mature, to the point I'm preparing to
document it.
What I've found, is that by using C++11 constructs it becomes much simpler
and, I dare say, intuitive than good old MPL. I argue, that perhaps that's
just simple enough.

As soon as I have it documented I'll share on this list, but If you'd be
interested in taking a look at it before I'm able to do so, you can find it
here:
https://github.com/brunocodutra/mpl2/tree/master/include/boost/mpl2/metafunctional

Unit tests, that serve as examples, can be found here:
https://github.com/brunocodutra/mpl2/tree/master/test/metafunctional

*Bruno C. O. Dutra*


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