The following snippet doesn't compile

I am trying to reflect on a class and only do an operation with all member functions of a class. But I can't seem to use a filter to only get the member functions out of a type T.

I understand that there are two errors in my snippet.
1) It cannot mixin a `name` because it is a variable from the lambda that `filter()` is using. 2) members.filter!(name => !ctorAndDtor.canFind(name)) does not filter on symbols defined in ctorAndDtor

How can I fix these problems and return all member functions whitout ctor and dtor of a type T?

Code snippet:

void main()
{
    GetFunctionMembers!Foo();
}

void GetFunctionMembers(T)()
{
    enum members = [__traits(derivedMembers, T)];
    pragma(msg, "Functions: " ~ members.stringof);

    enum ctorAndDtor = ["this", "__ctor", "__dtor"];
enum memberFunctions = members.filter!(name => !ctorAndDtor.canFind(name)
                && mixin("isFunction!(T." ~ name ~ ")"))();

    pragma(msg, memberFunctions);
}

class Foo
{
    bool myBool;
    int k;

    this()
    {
    }

    ~this()
    {
    }

    void bar(int k)
    {
        this.k = k;
    }

    void qux()
    {
    }
}

Reply via email to