digitalmars.D.learn - Overload sets and templates
- Nick Sabalausky (21/21) Feb 08 2014 This works:
- Timon Gehr (2/23) Feb 08 2014 What you are trying to do should work. I.e. this is a compiler bug.
- Nick Sabalausky (3/4) Feb 08 2014 Thanks. Filed:
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?
Feb 08 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.
Feb 08 2014
On 2/8/2014 11:35 AM, Timon Gehr wrote:What you are trying to do should work. I.e. this is a compiler bug.Thanks. Filed: https://d.puremagic.com/issues/show_bug.cgi?id=12111
Feb 08 2014








Nick Sabalausky <SeeWebsiteToContactMe semitwist.com>