[Issue 14802] Template argument deduction depends on order of arguments

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 16 22:11:14 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14802

--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Steven Schveighoffer from comment #4)
> However, I'll note that in other cases, the compiler prefers one over the
> other:
> 
> // both double[]
> auto arr = [1.0, 1.0f];
> auto arr2 = [1.0f, 1.0];
> 
> // both double
> auto x = true ? 1.0 : 1.0f;
> auto x2 = true ? 1.0f : 1.0;
> 
> same for uint vs. int

Yes, that's what I imagine. The type T deduction in:

 void f(T)(T x, T y) {}
 void main() { f(1.0, 1.0f); }

should be equivalent with:

 alias T = typeof(true ? 1.0 : 1.0f);

--


More information about the Digitalmars-d-bugs mailing list