Two functions with different args. Taking address of the one
Виталий Фадеев
vital.fadeev at gmail.com
Thu Mar 11 15:08:59 UTC 2021
On Thursday, 11 March 2021 at 14:23:39 UTC, Adam D. Ruppe wrote:
> On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев
> wrote:
>> _processMouseKey = &process; // <-- not works
>> _processMouseMove = &process; // <-- not works
>
> This *should* actually work. What type are those variables?
>
> struct MouseKeyEvent {}
> struct MouseMoveEvent{}
> void process( ref MouseKeyEvent event ) { }
> void process( ref MouseMoveEvent event ) { }
>
> void main() {
> // this works because the type is given on the left
> // so the compiler knows which overload works
> void function(ref MouseMoveEvent) processMouseMove =
> &process;
> }
I was stupid.
It is really simple!
Thank a lot, bro!
More information about the Digitalmars-d-learn
mailing list