It's not working for my case, while I see no special reason why
it couldn't. Also I can't find specific inference rules at
http://dlang.org/spec/function.html#function-templates
Is it a problem that the types to be inferred are in turn also
templated? Any workaround that can make inference wor
On 04/23/2017 09:33 PM, XavierAP wrote:
void assembleMass1D(Mat, Vec)(ref Mat M, const ref Vec x)
{ /* ... */ }
Matrix!(2,2) M = /* ... */;
Vector!2 V = /* ... */;
assembleMass1D(M, V); // ERROR template cannot deduce function from
argument types
Please post self-contained code. When I fill
On Sunday, 23 April 2017 at 19:40:39 UTC, ag0aep6g wrote:
Please post self-contained code. When I fill the gaps you left,
it works for me:
Interesting, thanks a lot. I'll test and narrow down what's in my
code preventing this from working (I can't really think of
anything) and I'll report b
On Sunday, 23 April 2017 at 19:40:39 UTC, ag0aep6g wrote:
Please post self-contained code. When I fill the gaps you left,
it works for me:
Found it! It stops working (DMD v2.073.0 for Windows) if it has
to infer the type of a temporary local variable -- constructed in
place of the argument:
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
On Tuesday, 25 April 2017 at 19:57:30 UTC, Ali Çehreli wrote:
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':
Aha I had forgotten about the ref (obviously, otherwise I
wouldn't have passed a
On 04/25/2017 01:02 PM, XavierAP wrote:
> It would be helpful if the error message talked about the ref qualifier
> as the root cause instead of the consequent failure to infer template
> parameters.
That's a common request but the solution is not implemented yet because
it's not trivial if you