"cannot deduce function from argument types" issue.
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 10 01:03:04 PST 2015
ted:
> Could someone enlighten me ?
This works:
import std.range: ElementType, isInputRange;
ElementType!R testFunc(R, T)(R range, T foo)
if (is(ElementType!R == T)) {
static assert(isInputRange!R);
typeof(return) retVal = foo ^^ 2; // More DRY.
return retVal;
}
void main() {
auto values = [0.0, 3.0, -1.0, 5.0];
auto result = testFunc(values, 8.8);
}
The D compiler seems unable to compute ElementType!R in the
function signature. If I am right, then this seems worth an
enhancement request.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list