class Foo
{
void func(double) { }
void func(int) { }
void set(T)(T handler) { dg = handler; }
void delegate(int) dg;
}
void main()
{
auto foo = new Foo;
foo.set(&foo.func); // NG, func(double) is picked up first
}
Error: cannot implicitly convert expression (handler) of
Andrej Mitrovic , dans le message (digitalmars.D.learn:30286), a écrit :
> class Foo
> {
> void func(double) { }
> void func(int) { }
>
> void set(T)(T handler) { dg = handler; }
> void delegate(int) dg;
> }
>
> void main()
> {
> auto foo = new Foo;
> foo.set(&foo.func);
So it seems this is an issue with a newer signals implementation.
The old one works:
import std.signals;
struct Foo
{
mixin Signal!(int) sig;
}
class Bar
{
void x(string) { }
void x(int) { }
}
void main()
{
Foo foo;
auto bar = new Bar;
foo.sig.connect(&bar.x);
foo.si
Andrej Mitrovic , dans le message (digitalmars.D.learn:30315), a écrit :
> The new one: https://gist.github.com/1194497
>
> I'll investigate this further then.
OK, so there is indeed a filter to find a suitable delegate to load:
@trusted T connect(T)(T handler) if(isHandler!(T, Types));
But onl