On Saturday, 9 July 2016 at 05:40:10 UTC, ag0aep6g wrote:

----
template bar(T, U...)
if (U.length > 1)
{
    import std.meta : staticMap;
    import std.typecons : Tuple;

    alias baz(A) = Tuple!(T, A);
    alias V = staticMap!(baz, U);
    alias TupleToFoo(T : Tuple!(Types), Types ...) = Foo!Types;
    // Alternative TupleToFoo with less complex syntax:
    // alias TupleToFoo(T) = Foo!(T.Types);
    alias bar = staticMap!(TupleToFoo, V);
}
----

Or with a more lightweight, custom wrapper:

----
template bar(T, U...)
if (U.length > 1)
{
    import std.meta : staticMap;

    template Box(stuff ...) { alias contents = stuff; }

    alias baz(A) = Box!(T, A);
    alias V = staticMap!(baz, U);
    alias BoxToFoo(alias box) = Foo!(box.contents);
    alias bar = staticMap!(BoxToFoo, V);
}
----

I'll give this a try. Thanks.

Reply via email to