On 12/22/15 10:40 AM, Adam D. Ruppe wrote:
In specialization, it will implicitly convert, it will just select the
best match available.
Make #1:
void func(T : ubyte)(T v) { writeln(1); }
It will then use that for for the second line because it is a *better*
match than :int, but :int stil
On Tuesday, 22 December 2015 at 15:29:16 UTC, Shriramana Sharma
wrote:
1) At func(100) why isn't the compiler complaining that it is
able to match two templates i.e. the ones printing 2 and 3?
Because the specialized one just wins the context. It only
complains when there's two equal ones.
C
import std.stdio;
void func(T)(T v) { writeln(1); }
void func(T: int)(T v) { writeln(2); }
void func(T)(T v) if (is(T: int)) { writeln(3); }
void main()
{
func(100);
ubyte s = 200;
func(s);
}
The above code prints 2 twice. A fwe questions:
1) At func(100) why isn't the compiler compla