Mutiple AliasSeq as input to template

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 25 10:56:12 PDT 2017


On Thursday, 25 May 2017 at 16:36:45 UTC, jmh530 wrote:
> [snip]

I haven't played around with it fully, but it seems like the 
following resolves my issue in a sort of manual way:

template Process1(A, B)
{
	static if (!isIndex!B)
		alias Process1 = A;
	else
		alias Process1 = B;
}

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





More information about the Digitalmars-d-learn mailing list