On 04/04/10 22:05, Daniel Ribeiro Maciel 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!
Based on Justin's code, I came up with this to remove the need to pass
the length of the TypeTuple:
----
import std.typetuple;
alias TypeTuple!(int, double, char[]) tupleA;
alias TypeTuple!(int, double, char[]) tupleB;
alias TypeTuple!(int, double, char*) tupleC;
// Method 1: write an is() each time
pragma(msg, (is(tupleA == tupleB)).stringof);
pragma(msg, (is(tupleA == tupleC)).stringof);
template compare(string t1, string t2)
{
enum compare = mixin("is("~t1~"=="~t2~")");
}
// Method 2: Use the above template and pass strings
pragma( msg, compare!("tupleA", "tupleB") );
pragma( msg, compare!("tupleA", "tupleC") );
----