Overload sets and templates
Timon Gehr
timon.gehr at gmx.ch
Sat Feb 8 08:35:42 PST 2014
On 02/08/2014 10:46 AM, Nick Sabalausky wrote:
> This works:
>
> ------------------------------
> void foo(T)(T t) if(is(T==char)) {}
> void foo(T)(T t) if(is(T==int )) {}
>
> void main() { foo(1); }
> ------------------------------
>
> But if I move the "int" version to a different module, and try to alias
> it into the current module's overload set (like I can with non-templated
> functions), I just get an error that the "char" version of foo conflicts
> with the alias:
>
> ------------------------------
> module a;
> import b;
>
> alias foo = b.foo;
> void foo(T)(T t) if(is(T==char)) {}
>
> void main() { foo(1); }
> ------------------------------
> module b;
> void foo(T)(T t) if(is(T==int)) {}
> ------------------------------
>
> What's up with that? Is there a way to do it?
What you are trying to do should work. I.e. this is a compiler bug.
More information about the Digitalmars-d-learn
mailing list