struct mixins
Leandro Lucarella
llucax at gmail.com
Mon Nov 16 09:32:12 PST 2009
Frank Benoit, el 16 de noviembre a las 16:58 me escribiste:
> Reminds me of an older thread:
> http://www.digitalmars.com/d/archives/digitalmars/D/Implicit_castable_structs_64764.html
I think mixin can mix very well with that proposal, when the compiler sees
a struct mixin, it can automatically provide an {im,ex}plicit cast to the
mixed in type, adjusting the pointer:
struct A {
int x;
}
struct B {
int y;
}
struct C {
mixin A;
mixin B;
}
C* c = new C;
A* a = cast(A*) c; // points to c
B* a = cast(B*) c; // points to c + A.sizeof
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Cómo ser inconmensurablemente atractivo a la mujer del sexo opuesto.
-- Libro de autoayuda de Hector Mesina.
More information about the Digitalmars-d
mailing list