On 04/25/2017 12:19 PM, XavierAP wrote: > void assembleMass1D(Mat, Vec)(ref Mat M, const ref Vec x) > { /* ... */ } > > Matrix!(2,2) M; > Vector!2 V; > assembleMass1D(M, V); // OK > assembleMass1D(M, Vector!2()); // ERROR template cannot deduce function > > > Is this a bug?
This is an intentional limitation of D. It's not possible to bind rvalues (temporaries) to reference parameters. The best option here is 'auto ref':
void assembleMass1D(Mat, Vec)(auto ref Mat M, auto ref const(Vec) x) { /* ... */ } Ali