How do I assign attributes of a function to another function?

Stanislav Blinov stanislav.blinov at gmail.com
Fri Nov 5 18:14:20 UTC 2021


On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote:

...e.g.
```d
// ...
mixin ("ReturnType /*...snip...*/ " ~ member ~ "()(Parameters! 
/*...snip...*/
```

Note the `()` before parameter list. This would make your member 
function a function template, for which attributes will be 
inferred by the compiler based on the calls you make in the 
function body.

Of course, making it a template like this makes it non-composable 
with that same type as you're only inspecting functions, so you 
wouldn't be able to do e.g. a Group!(Group!(A, 3), 4);


More information about the Digitalmars-d-learn mailing list