[Issue 2704] Constness lost when passing a struct member by alias

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 17 11:34:53 UTC 2019


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

Max Samukha <maxsamukha at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxsamukha at gmail.com

--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
Would that break tons of reflective code like this?

// any template extracting compile-time info
template hasAttr(alias symbol, alias attr) {
        import std.meta;
        enum _f(alias s) = __traits(isSame, s, attr);
        alias hasAttr = anySatisfy!(_f, __traits(getAttributes, symbol));
}

struct attr {
}

int main() {
        @attr int x;
        static assert(hasAttr!(x, attr)); // wouldn't work anymore
        return 0;
}

--


More information about the Digitalmars-d-bugs mailing list