Re: ref barfs template parameter deduction?

2020-05-08 Thread NaN via Digitalmars-d-learn
On Friday, 8 May 2020 at 22:11:57 UTC, Paul Backus wrote: On Friday, 8 May 2020 at 22:03:47 UTC, NaN wrote: The integer literal `1` is an rvalue, and can't be passed by reference. If you explicitly instantiate the templates foo and bar in the function call, you get a more informative error

Re: ref barfs template parameter deduction?

2020-05-08 Thread Paul Backus via Digitalmars-d-learn
On Friday, 8 May 2020 at 22:03:47 UTC, NaN wrote: void bar() { bam(foo(1)); } if you change the declaration of foo or bam to "ref T x", ie.. auto foo(T)(ref T x) auto bam(T)(ref T x) then the compiler complains thus... ldc 1.17.0 (Editor #1, Compiler #1) D#1 with ldc 1.17.0 (23): Error:

ref barfs template parameter deduction?

2020-05-08 Thread NaN via Digitalmars-d-learn
Ok given the following code... auto foo(T)(T x) { struct V1 { T* what; } V1 v; return v; } auto bam(T)(T x) { struct V2 { T* what; } V2 v; return v; } void bar() { bam(foo(1)); } if you change the declaration of foo or bam to "ref T x", ie.. auto foo(T)(ref T x)

Re: ref barfs template parameter deduction?

2020-05-08 Thread NaN via Digitalmars-d-learn
On Friday, 8 May 2020 at 22:03:47 UTC, NaN wrote: Ok given the following code... auto foo(T)(T x) { struct V1 { T* what; } V1 v; return v; } auto bam(T)(T x) { struct V2 { T* what; } V2 v; return v; } void bar() { bam(foo(1)); } Should have said that compiles

Re: Template Parameter Deduction

2015-03-12 Thread Paul D Anderson via Digitalmars-d-learn
, it looks like there is a hiccup in the template parameter deduction code and that it is being fixed. And it's easy to work around. I'll dig a little deeper to see if I can find a related bug report. Paul

Re: Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 22:44:12 UTC, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context

Re: Template Parameter Deduction

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 03:44 PM, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context context = T.context)

Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context context = T.context) if (isDecimal!T isIntegral!U) // two