| Thread overview | |||||
|---|---|---|---|---|---|
|
February 08, 2014 Overload sets and templates | ||||
|---|---|---|---|---|
| ||||
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?
| ||||
February 08, 2014 Re: Overload sets and templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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.
| |||
February 08, 2014 Re: Overload sets and templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply