Re: How to get the location (file, line) of UDA without parens?

2021-11-14 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 14 November 2021 at 07:06:25 UTC, user1234 wrote: On Sunday, 14 November 2021 at 05:12:58 UTC, Andrey Zherikov wrote: Here is my code: [...] `W()` (2) works as expected but is it possible to achieve the same without parenthesis so `getAttributes` trait returns `tuple(L("app.d",

Re: How to get the location (file, line) of UDA without parens?

2021-11-13 Thread user1234 via Digitalmars-d-learn
On Sunday, 14 November 2021 at 05:12:58 UTC, Andrey Zherikov wrote: Here is my code: [...] `W()` (2) works as expected but is it possible to achieve the same without parenthesis so `getAttributes` trait returns `tuple(L("app.d", 16LU))` for (1)? No, without parens this is really the function

How to get the location (file, line) of UDA without parens?

2021-11-13 Thread Andrey Zherikov via Digitalmars-d-learn
Here is my code: ```d struct L { string file; size_t line; } auto W(string f = __FILE__,size_t l= __LINE__)() { return L(f,l); } struct A { @W // (1): line# 16 { int a; int b; } @W() // (2): line# 21 { int c; int d; } } void main() {