enum Format

Nickolay Bukreyev buknik95 at ya.ru
Thu Jan 11 04:31:32 UTC 2024


On Thursday, 11 January 2024 at 02:35:00 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> ```d
> void func(T...)(T args) {
>     pragma(msg, __traits(getAttributes, args[1])); // 
> format("format")
> }
> ```

Sorry, I don’t understand how this can possibly work. After 
`func` template is instantiated, its `T` is bound to, e.g., 
`AliasSeq!(string, int, string)`. `args` is just a local variable 
of type `AliasSeq!(string, int, string)`. How can `__traits` know 
what attributes were attached at call site?

If, on the other hand, attributes do affect the type, then IMHO

```d
func("prefix", @format("format") expr, "suffix");
```

is not much different than

```d
func("prefix", format!"format"(expr), "suffix");
```

I.e., we can do it already.


More information about the Digitalmars-d mailing list