On 2019-04-11 20:13, Alex wrote:
The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
    static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would fail with the static if but pass without it but in the first case I get no attributes because the __traits compiles fails.



__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the foreach?

The problem is that "__traits(getAttributes, T)" in it self is not valid code. It needs to be part of larger expression or statement. The following seems to work:

https://run.dlang.io/is/JWkdbQ

--
/Jacob Carlborg

Reply via email to