Can we just have struct inheritence already?

Manu turkeyman at gmail.com
Sun Jun 9 08:05:34 UTC 2019


I am really really tired of this pattern:

struct DerivedStruct
{
    static if (BaseStruct.tupleof.length > 0)
        BaseStruct base;
    else
        ref inout(BaseStruct) base() inout { return
*cast(inout(BaseStruct)*)&this; }
    alias base this;

    // derived members
    //...
}

Imagine if we could just write:

struct DerivedStruct : BaseStruct
{
    // derived members
    //...
}

Just imagine!


More information about the Digitalmars-d mailing list