On 30-7-2013 14:48, Dicebot wrote:
On Tuesday, 30 July 2013 at 12:37:26 UTC, Faux Amis wrote:
I do not understand what this code should help with:

struct LAYER(BASE)
{
    BASE base;
    // ... use base ...
}

Any advice on what I should read to get it?
(no C++ exp)

It is meant to do "has-a" (http://en.wikipedia.org/wiki/Has-a)
inheritance with only exception - it should not be as is not an
inheritance. :) Common way to achieve code re-usage without defining
meaningless hierarchies.

like this:?

struct LAYER(BASE)
{
        BASE base;
        // ... use base ...
        void func(){};
}

struct Base
{
        alias LAYER!(Base) Layer;
        Layer layer;
        layer.base = this;
        layer.func();
    // ...
}

Reply via email to