Sean Eskapp <eatingstap...@gmail.com> wrote:
I have a variable of type TypeTuple!(int, int), and I want to convert
all its
elements into a variable of type TypeTuple!(string, string). Is there a
way to
do this? Using a loop fails compilation with "Error: Integer constant
expression expected instead of i".
Just to be sure, you want something( TypeTuple!(int, int) ) to yield
TypeTuple!( TypeTuple!(string, string), TypeTuple!(string, string) )?
This could be done by means of std.traits' staticMap in conjunction with
a custom template:
template replace( T ) {
alias TypeTuple!(string, string) replace;
}
alias staticMap!( replace, TypeTuple!( int, int ) ) myNewTuple;
static assert( myNewTuple.stringof == TypeTuple!( TypeTuple!(string,
string), TypeTuple!(string, string) ).stringof );
I'd also like to be able to convert from arrays of base classes (static
size)
to TypeTuples of derived classes. "static for" doesn't work either. Is
there a
way to do this.. without a recursive template function?
Not that I know of. Recursive templates are fun, though.
--
Simen