On Wednesday, 6 April 2022 at 18:21:11 UTC, Adam D Ruppe wrote:
On Wednesday, 6 April 2022 at 18:10:32 UTC, Guillaume Piolat wrote:
Any idea how to workaround that?

Works fine if you just use the language instead of the buggy phobos wrappers:

---
    struct MyUDA
    {
    }

    class A
    {
        @MyUDA int a;
    }

    class B : A
    {
        @MyUDA int b;
    }

    void main()
    {
        foreach(memberName; __traits(allMembers, B))
foreach(attr; __traits(getAttributes, __traits(getMember, B, memberName)))
        static if(is(attr == MyUDA))
                pragma(msg, memberName); // a, b
    }
---

So make a function that does that and applies whatever it is you need to apply and you're in business.

Note that it is `is(typeof(attr) == MyUDA)` if defined `@MyUDA(args)`.

Thanks, it will also create less templates.

Reply via email to