template <typename Pipe>
struct Unwrap {
template <typename Wrapped>
using f = /* .... */;
};
Unwrap<Pipe>
is a metafunction that passes to Pipe
the parameter pack Ts...
, which is generated unwrapping the outermost template of Template<Ts...>
.
f:: Wrapper<Ts...> -> Ts... >-> Pipe
Wrapped
needs to be an instantiation of a class template, Template<Ts...>
.
ml::Unwrap
is usually used to unwrap the elements of a list-like and pass them to a metafunction Pipe
expecting a parameter pack. It should be rarely needed, as you should strive for chaining metafunctions via Pipe
s (where parameter packs are forwarded). In general, there are two situations where you might need it:
- you are already holding a list-like, and need to invoke a metafunction on the parameters it is holding, or
- you need to compose two concrete metafunctions via
ml::Compose
(because you do not have access to setting theirPipe
s), and the first returns a list-like.
Suppose we have two concrete metafunctions (with no access to their Pipe
parameters).
using cF0 = ml::Pivot<2>;
using cF1 = ml::Map<ml::Increment<>>;
They cannot be composed, because cF0
returns an ml::ListT
, and cF1
expects a parameter pack. So we ml::Unwrap
.
using T0 = ml::f<
ml::Unwrap<cF1>,
ml::f<
cF1,
ml::Int<0>, ml::Int<1>, ml::Int<2>>>
We can use ml::Compose
, instead of invoking twice.
using F = ml::Compose<
ml::Unwrap<cF1>,
cF0>;
using T1 = ml::f<
F,
ml::Int<0>, ml::Int<1>, ml::Int<2>>;