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
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:
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)
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
, 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
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
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)
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