Passing variadic template parameters AND default call site __FILE__, __LINE__ template parameters.

realhet real_het at hotmail.com
Wed May 28 10:13:43 UTC 2025


On Tuesday, 27 May 2025 at 21:16:57 UTC, monkyyy wrote:
> On Tuesday, 27 May 2025 at 21:07:51 UTC, realhet wrote:

I stay in safety and choose this way:

```d
enum _LOCATION_(string FILE=__FILE__, size_t LINE=__LINE__) = 
FILE~'('~LINE.text~",1)";

enum loc1 = (_LOCATION_!());
enum loc2 = (_LOCATION_!());
```

We just can't eliminate the !() with alias, it's mandatory.

And I write this signature `(_LOCATION_!())` to every place where 
it is needed.  But not by myself, by my machine.  It will be 
hidden in my editor to reduce visual noise.

Maybe I can make it more type-safe by not returning a string 
`"file.d(12,1)"`, but returning a struct.  Howerer IES also 
starts and ends with special structs, easy to detect those.


More information about the Digitalmars-d-learn mailing list