On 2015-07-14 17:28, Rene Zwanenburg wrote:
Given the following code:class Base { alias CallbackType = void delegate(Base); CallbackType callback; void foo() { callback(this); } } class Derived : Base { } void main() { auto d = new Derived(); d.callback = (Derived d) { /* Do something */ } } Obviously this won't compile, since the callback function needs to have Base as parameter, not Derived.
You can cast the delegate. It's probably unsafe but a simple example works. -- /Jacob Carlborg