Comparing Two Type Tuples

BCS none at anon.com
Mon Apr 5 08:47:10 PDT 2010


Hello Justin Spahr-Summers,

> On Mon, 5 Apr 2010 02:59:15 +0000 (UTC), BCS <none at anon.com> wrote:
> 
>> 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)
>> 
> Definitely a lot cleaner. I'm curious, though... is there a reason to
> avoid is(T == U)?
> 

I dind't know it worked?

-- 
... <IXOYE><





More information about the Digitalmars-d-learn mailing list