On 09/24/2014 01:11 AM, andre wrote:

> template MyTemplate()
> {
>      import std.traits : isSomeFunction, functionAttributes,
> FunctionAttribute, ReturnType;
>
>      string[] getPropertyNames()

1) You need a "this template parameter":

    string[] getPropertyNames(this MyType)()

2) Now, replace all typeof(this) expressions with MyType below.

>      /*string[] getPropertyDuplicate()

3) Same here:

    string[] getPropertyDuplicate(this MyType)()

And it works! :)

class A {
    mixin MyTemplate;
    @property int zzz()
    {
        return 42;
    }
}

void main() {
    auto a = new A();

    import std.string;
    assert(a.getPropertyNames() == [ "zzz" ]);
    assert(a.getPropertyDuplicate() == [ "zzz" ]);
}

Ali

Reply via email to