It is a bug?
Jack Applegame
japplegame at gmail.com
Mon Mar 29 17:57:53 UTC 2021
This code doesn't compile:
> import std.stdio;
>
> struct Foo { @(123) int t; }
>
> void printUDA(alias bar)() {
> writeln(__traits(getAttributes, bar));
> }
>
> void main() {
> printUDA!(Foo.t); // Error: need this for printUDA of type
> @safe void()
> }
but I found a funny workaround:
> import std.stdio;
>
> struct Foo { @(123) int t; }
>
> static void printUDA(alias bar)() { // <------- add static
> writeln(__traits(getAttributes, bar));
> }
>
> void main() {
> printUDA!(Foo.t);
> }
Looks weird.
More information about the Digitalmars-d
mailing list