Partial application of compile time args type deduction

QAston via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 19 15:37:56 PST 2016


Hi,

I have the following code:

auto appendMapped(alias f, R, T)(R r, T elem) {
	r ~= f(elem);
	return r;
}

int minus(int i) {
	return -i;
}

unittest {
	int[] ar;
         // here I do partial application of minus function
	alias appendMinus(S,T) = appendMapped!(minus, S, T);
	assert (appendMinus!(int[], int)(ar, 10) == [-10]); // compiles
	assert (appendMinus(ar, 10) == [-10]); // doesn't compile
}

Which gives me following error:
Error: template transduced.__unittestL111_2.appendMinus cannot 
deduce function from argument types !()(int[], int), candidates 
are:  transduced.__unittestL111_2.appendMinus(S, T)

Is there a way to do partial template arg application which does 
template type deduction correctly?


More information about the Digitalmars-d-learn mailing list