Comparing Two Type Tuples

Simen kjaeraas simen.kjaras at gmail.com
Sun Apr 4 17:08:49 PDT 2010


Daniel Ribeiro Maciel <danielmaciel at gmail.com> 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!

This should work, but doesn't (filing a bugzilla about it now):

template compareTuple( T... ) {
     template compareTuple( U... ) {
         enum bool compareTuple = is( T == U );
     }
}

static assert( compareTuple!( int, float )!( int, float ) );

However, this works:

alias compareTuple!( int, float ) foo;
static assert( foo!( int, float ) );

-- 
Simen


More information about the Digitalmars-d-learn mailing list