digitalmars.D.learn - Using template typetuples?
- Sean Eskapp <eatingstaples gmail.com> Jan 12 2011
- "Simen kjaeraas" <simen.kjaras gmail.com> Jan 12 2011
- Sean Eskapp <eatingstaples gmail.com> Jan 12 2011
- Sean Eskapp <eatingstaples gmail.com> Jan 12 2011
The language documentation covers some basic uses of TypeTuples in templates, but nothing about using them with classes. I would like a template class, which essentially wraps a function, which has template parameters for return value and template tuple arguments. However, what if I want to convert a TypeTuple of int, double, string to its respective Function-wrapped TypeTuple, i.e. Function!int, Function!double, Function!string. Is there any way to do so?
Jan 12 2011
Sean Eskapp <eatingstaples gmail.com> wrote:The language documentation covers some basic uses of TypeTuples in templates, but nothing about using them with classes. I would like a template class, which essentially wraps a function, which has template parameters for return value and template tuple arguments. However, what if I want to convert a TypeTuple of int, double, string to its respective Function-wrapped TypeTuple, i.e. Function!int, Function!double, Function!string. Is there any way to do so?
std.typetuple has staticMap, which sounds like what you want: alias TypeTuple!( int, double, string ) tup; alias staticMap!( Function, tup ) functions; Is this what you want? -- Simen
Jan 12 2011
That looks like it.. only, it's not working:
void main()
{
TypeTuple!(int, int) foo;
foo[0] = 1;
foo[1] = 2;
double MakeStuff(in int bar)
{
return cast(double)bar;
}
auto foobar = staticMap!(MakeStuff)(foo);
}
This fails compilation with the error "Error: function expected before (), not
()
of type ()"
Jan 12 2011








Sean Eskapp <eatingstaples gmail.com>