www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Comparing TypeTuples

reply "Tudor Berariu" <tudor.berariu gmail.com> writes:
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
Sep 02 2014
parent "monarch_dodra" <monarchdodra gmail.com> writes:
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]); }
Sep 02 2014