Inherit

Inheritance mixin

Description: Inserts structs specified by PT type tuple as members and a dispatcher method that statically transfers any method calls and member accesses to corresponding child struct.

Alias This

_parent

Members

Aliases

_parentTypeTuple
alias _parentTypeTuple = PT
Undocumented in source.

Templates

opDispatch
template opDispatch(string s)
Undocumented in source.

Variables

_parent
PT _parent;
Undocumented in source.

Examples

struct Foo
{
    int x = 100;
    int foo() { return 11; }
}

struct Bar
{
    int y = 99;
    int bar() { return 22; }
}

struct TestObj
{
    mixin Inherit!(Foo, Bar);
}

TestObj obj;

obj.x *= 2;
obj.y = 10;

assert(obj.x == 200);
assert(obj.y == 10);

assert(obj.foo() == 11);
assert(obj.bar() == 22);

Meta