Two functions with different args. Taking address of the one

Adam D. Ruppe destructionator at gmail.com
Thu Mar 11 14:23:39 UTC 2021


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;
}


More information about the Digitalmars-d-learn mailing list