As C++ metaprogramming is functional: is there any way of doing something comparable to any functional programming language's (e.g. Haskell's) let or where construct?
I'm using Boost::MPL but would like to have more structure for longer metafunctions. Splitting into several functions is fine but I'd prefer let/where in some cases.
The MPL itself doesn't support let
clauses but some of the libraries built on top of it do. One example is metamonad. As the name suggests it also supports some other higher-level functional concepts (monads). A big drawback is, that metamonad
is not an official part of the Boost distribution.
As far as work-arounds for the MPL go, splitting things into functions and using more namespaces to group them and then import the important symbol into your top-level namespace is probably your best choice.