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 context = T.context)
    if (isDecimal!T && isIntegral!U)
// two different template parameters for the two input values

then

3) dec9 arg1 = dec9("1.20");
   long arg2 = 3;
   result = mul(arg1, arg2);
   // correctly deduced function

But now (D2.066.1) either 1) has to be changed to

1) public T mul(T, U)(in T x, U y, Context context = T.context)
    if (isDecimal!T && isDecimal!U)
// two identical template parameters for the two input values

or 3) has to be changed to

3) dec9 arg1 = dec9("1.20");
   long arg2 = 3;
   result = mul!(dec9,long)(arg1, arg2);
   // template parameters have to be made explicit

Is this expecded behavior?

Paul

This works with 2.066.1 and git HEAD

import std.stdio;
void mul(T)(in T x, in T y, long i = T.init)
if (is(T == int))
{
    writeln("same");
}

void mul(T, U)(in T x, U n, long i = T.init)
if (is(T == int) && is(U == ulong))
{
    writeln("different");
}

void main()
{
    mul(1,2);
    mul(1,2UL);
}


Perhaps there is something important in your incomplete example that I have missed out.

Reply via email to