Variadic Tuple of Structs with Mixed Types
jmh530 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 8 15:33:31 PDT 2016
I'm trying to create a tuple of variadic length containing
structs with mixed types. So for instance, given
struct Foo(T, U)
{
T x;
U y;
}
I want to create something like
Tuple!(Foo!(type1, type2), Foo!(type1, type3), ..., Foo!(type1,
typeN)) x;
The bar function (below) is what I've tried to use to create it.
template bar(T, U...)
if (U.length > 1)
{
import std.meta : staticMap;
template baz(A)
{
import std.meta : AliasSeq;
alias baz = AliasSeq!(T, A);
}
alias V = staticMap!(baz, U);
alias bar = staticMap!(Foo, V);
}
void main()
{
import std.typecons : Tuple;
Tuple!(bar!(int, float, int)) x;
}
My strategy was getting something like
AliasSeq!(AliasSeq!(type1, type2), AliasSeq!(type1, type3), ... )
and then I can staticMap over that with Foo in order to create
the correct type.
However, I can't seem to get it working.
Any ideas?
More information about the Digitalmars-d-learn
mailing list