On Thursday, 15 November 2018 at 17:14:21 UTC, Carl Sturtivant wrote:
opDispatch is special in that it allows for functions to be added to a class or struct when undefined overtly but used elsewhere but it seems those functions sadly are final.

Right, all templates are final, including opDispatch.

What I've done in the past is to forward them to a virtual function with runtime arguments instead of compile time arguments.

Kinda like:

void opDispatch(string name)() {
     callMethod(name);
}

/* virtual */ void callMethod(string name) {
// do a reflection loop or associate array or switch or whatever to dispatch it here, reimplemented (or at least re-mixed-in) in the child classes to account for their new methods
}



What exactly do you need to do with it? Maybe you can do an alternative design.

Reply via email to