https://issues.dlang.org/show_bug.cgi?id=9748

Mathias LANG <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Mathias LANG <[email protected]> ---
Real world use case where I hit this bug:

import std.typetuple, std.traits;

struct UDAStruct {
    string identifier;
}

class MyClass {
    @(UDAStruct("p3"), UDAStruct("P2"), UDAStruct("p1"))
      void func(int p1, string p2, float p3) {}
}

template CmpIdentifier(UDAStruct uda, string pname) {
    pragma(msg, "Instantiated for: "~pname);
    enum CmpIdentifier = (uda.identifier == pname);
}

unittest {
    alias Func = MyClass.func;
    enum ParamNames = ParameterIdentifierTuple!Func;
    enum ParamAttr = __traits(getAttributes, Func);

    foreach (attr; ParamAttr) {
        alias Cmp(string s) = CmpIdentifier!(attr, s);
        pragma(msg, "Current attr is: "~attr.identifier);
        static assert(anySatisfy!(Cmp, ParamNames));
    }
}

void main() {}


Output:
Current attr is: p3
Instantiated for: p1
Instantiated for: p2
Instantiated for: p3
Current attr is: P2
Current attr is: p1

(From: http://forum.dlang.org/thread/[email protected] )

--

Reply via email to