Mutiple AliasSeq as input to template

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 25 09:36:45 PDT 2017


I'm trying to process one AliasSeq based on the types in another. 
I've tried to sketch it out below. However, it doesn't work 
because when you combine together two AliasSeq's in the template, 
then it creates one AliasSeq.

The only other thing I considered was a staticMap with isIndex, 
but I wasn't sure if it would work with two AliasSeqs.


enum isIndex(I) = is(I : size_t);

template Process(A, B)
{
	import std.meta : AliasSeq;
	
	static if (A.length == 1)
	{
		static if (!isIndex!B[0])
			alias Process = AliasSeq!(A[0]);
		else
			alias Process = AliasSeq!(B[0]);
	}
	else static if (A.length > 1)
	{
		static if (!isIndex!B[0])
			alias Process = AliasSeq!(A[0], Process!(A[1..$], B[1..$]));
		else
			alias Process = AliasSeq!(B[0], Process!(A[1..$], B[1..$]));
	}
}

void main()
{
	import std.meta : AliasSeq;

	alias T = AliasSeq!(int[], int[]);
	alias U = AliasSeq!(int, string);
	alias V = Process!(T, U); //result should be AliasSeq!(int, 
int[])
}


More information about the Digitalmars-d-learn mailing list