struct mixins

Denis Koroskin 2korden at gmail.com
Mon Nov 16 08:03:33 PST 2009


On Mon, 16 Nov 2009 18:58:42 +0300, Frank Benoit  
<keinfarbton at googlemail.com> wrote:

> Reminds me of an older thread:
> http://www.digitalmars.com/d/archives/digitalmars/D/Implicit_castable_structs_64764.html

I recall it, but I still think "alias this" is the way to go:

struct GtkWidget{ /* data member */ }

struct GtkContainer{
     GtkWidget widget; // mixin GtkWidget; could also work, though
     // more data members

     alias this &widget; // how would you do the same without a named mixin?
     // And what's the benefit of named mixin over plain old aggregation?
}



More information about the Digitalmars-d mailing list