Comparing Two Type Tuples

BCS none at anon.com
Sun Apr 4 19:59:15 PDT 2010


Hello Daniel,

> 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!
>

here is my untested vertion:

template Compare(T...)
{
    template With(U...)
    {
        static if(T.length != U.lenght) const bool With = false;
        else static if(T.length == 0) const bool With = true;
        else static if(is(T[0] == U[0])) const bool With = Compare!(T[1..$]).With!(U[1..$]);
        else const bool With = false;
    }
}

use like: Compare!(int, float, myStruct).With(alias1,alias2,typeArg)
 
-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list