Re: Trying to understand something about UDAs.

2016-12-12 Thread Kevin Balbas via Digitalmars-d-learn
On Monday, 12 December 2016 at 19:56:27 UTC, Adam D. Ruppe wrote: But the static if(is(UDA)) is probably what you actually want. That's exactly what I was looking for, thanks. I'm not sure I ever would've figured out that one on my own.

Re: Trying to understand something about UDAs.

2016-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 12 December 2016 at 19:37:42 UTC, Kevin Balbas wrote: I'm trying to figure out how to test whether a UDA struct was initialized with arguments (and change the behavior of the surrounding code if it was. Easy solution: test the type. @Attr is setting the type as a UDA,

Trying to understand something about UDAs.

2016-12-12 Thread Kevin Balbas via Digitalmars-d-learn
I'm trying to figure out how to test whether a UDA struct was initialized with arguments (and change the behavior of the surrounding code if it was. While I was tinkering around with test files, I came up with this little gem: import std.traits; struct Attr { string str; }