Why doesn't symbol wheelbarrowing work with function templates?
TommiT
tommitissari at hotmail.com
Thu Jun 13 03:52:54 PDT 2013
Well, I guess wheelbarrowing works with templates similar to
functions if the template arguments are specified:
Doesn't work:
------------
import a;
import b;
void main()
{
// Ambiguity errors:
writeln(bar!string(int.init));
writeln(bar!string(char.init));
}
Works:
------
import a;
import b;
alias bar = a.bar!string;
alias bar = b.bar!string;
void main()
{
writeln(bar(int.init)); // 43
writeln(bar(char.init)); // 3
}
... but I just realized I'm not actually asking what I'm trying
to ask here. So, let me rephrase my question:
Why is the following ambiguous?
-----------
module a;
int foo(T)() if (is(T == int))
{
return 42;
}
-----------
module b;
int foo(T)() if (is(T == char))
{
return 3;
}
-----------
module main;
import std.stdio;
import a;
import b;
void main()
{
writeln(foo!int()); // Error: ambiguous template declaration
}
More information about the Digitalmars-d
mailing list