On Sun, 4 Apr 2010 21:05:49 +0000 (UTC), Daniel Ribeiro Maciel
<[email protected]> wrote:
>
> Heya ppl!
>
> I was wondering how could I write a function that takes two Type
> Tuples as arguments and returns true if they are match.
>
> Could anyone help me with this?
>
> Thanks!
You can really only pass a single type tuple to a template, but you can
work around it by passing a length and then comparing two parts of a
combined tuple. For instance:
import std.stdio;
import std.typetuple;
void compare(uint LEN, TL ...) () {
writefln("%s", is(TL[0 .. LEN] == TL[LEN .. $]));
}
void main() {
alias TypeTuple!(int, double, char[]) tupleA;
alias TypeTuple!(int, double, char[]) tupleB;
alias TypeTuple!(int, double, char*) tupleC;
compare!(tupleA.length, tupleA, tupleB);
compare!(tupleA.length, tupleA, tupleC);
}
will output "true" then "false."