Comparing TypeTuples

2014-09-02 Thread Tudor Berariu via Digitalmars-d-learn
How can I check if two TypeTuples containing both types and 
values are the same?

This fails:

  static assert(is(TypeTuple!(3, int, Zorro) == TypeTuple!(3, 
int, Zorro)));


Thank you!
Tudor


Re: Comparing TypeTuples

2014-09-02 Thread monarch_dodra via Digitalmars-d-learn

On Tuesday, 2 September 2014 at 08:27:14 UTC, Tudor Berariu wrote:
How can I check if two TypeTuples containing both types and 
values are the same?

This fails:

  static assert(is(TypeTuple!(3, int, Zorro) == TypeTuple!(3, 
int, Zorro)));


Thank you!
Tudor


Yeah, this fails because you can't use is(a == b) with values. 
However, *you* use is(a) to check if a is an actual type. Then, 
you can do something like:


alias Args1 = TypeTuple!(3, int, Zorro);
alias Args2 = TypeTuple!(3, int, Zorro);
static assert(Args1.length == Args2.length);
foreach (I, _; Args1)
{
pragma(msg, I);
static assert(is(Args1[I]) == is(Args2[I]));
static if (is(Args1[I]))
static assert(is(Args1[I] == Args2[I]));
else
static assert(Args1[I] == Args2[I]);
}