Boost logo

Boost :

Subject: Re: [boost] "Simple C++11 metaprogramming"
From: pfultz2 (pfultz2_at_[hidden])
Date: 2015-05-31 14:05:31

> If one day we have static constexpr lambdas, wouldn't we be able to use
> some kind of lambda meta-functions

We don't need constexpr lambdas to achieve this. We can do higher-order type
computations using dependent typing. I show here how to implement boost
filter so it will take a lambda rather than a MPL placeholder expression:

Which is based on the ideas presented by Zach Laine and Matt Calabrese
years ago at boostcon. So in essence you can write this in C++14:

    auto numbers = simple_filter(some_fusion_sequence, [](auto x)
        return is_integral<decltype(x)>() or

There is no `constexpr` required by the user. It all happens through
typing. This is how Boost.Hana works as well. Furthermore, Boost.Hana is not
`constexpr`-metaprogramming(athough it makes use of `constexpr`), it is
dependently-typed metaprogramming, which is much more powerful in current

> Is not that what the proposed Boost.Hana and Boost.Fit do already using
> a specific trick?

That trick, in general, is only used to achieve `constexpr` initialization
lambdas, which is necessary when declaring global lambdas. In can be used in
other ways to allow type deduction of lambdas in a `constexpr` context.
in general, with dependently-typed metaprogramming this isn't necessary.


View this message in context:
Sent from the Boost - Dev mailing list archive at

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