On Monday, 20 June 2016 at 00:01:58 UTC, Joerg Joergonson wrote:
I have a gui based on the following classes:
public class Widget { Widget Parent; }
public class Item : Widget;
public class Button(T : ButtonItem) : Widget { T[] Items; ... }
public class ButtonItem : Item
{
void Do() { auto parent =
(cast(Button!ButtonItem)this.Parent); ...}
...
}
What you ask for is called template covariance. D doesn't have it.
You can solve your problem by providing
Button!ButtonItem-specific functionality in an intermediate
ButtonBase class: https://dpaste.dzfl.pl/4c071b237aa0