Comparing Two Type Tuples

bearophile bearophileHUGS at lycos.com
Mon Apr 5 03:23:29 PDT 2010


Justin Spahr-Summers:
> Definitely a lot cleaner. I'm curious, though... is there a reason to 
> avoid is(T == U)?

I agree, I think the best answer is to not use a function/template, and just use the is(==) operator:

import std.stdio: writeln;

import std.typetuple;

void main() {
    alias TypeTuple!(int, double, char[]) A;
    alias TypeTuple!(int, double, char[]) B;
    alias TypeTuple!(int, double, char*) C;
    alias TypeTuple!(int, double) D;
    writeln(is(A == B));
    writeln(is(A == C));
    writeln(is(A == D));
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list