digitalmars.D.learn - Comparing TypeTuples
- Tudor Berariu (7/7) Sep 02 2014 How can I check if two TypeTuples containing both types and
- monarch_dodra (16/23) Sep 02 2014 Yeah, this fails because you can't use "is(a == b)" with values.
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
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! TudorYeah, 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