How can I get the variable name passed as parameter from within a function?
Jack
jckj33 at gmail.com
Fri Feb 26 19:41:45 UTC 2021
On Friday, 26 February 2021 at 19:37:34 UTC, Adam D. Ruppe wrote:
> On Friday, 26 February 2021 at 19:32:52 UTC, Jack wrote:
>> I managed to do this with alias parameter in a template:
>
> this is the only way, it needs to be an alias template
>
>> Also, can I short this template function somehow to syntax
>> f!(a) omitting the g?
>
> rename g to f. If the function inside the template's name
> matches the template's own name, the compiler combines them.
>
> of course at that point you can also just write it
>
> void f(alias var)() {
> // do your magic
> }
thanks! i was confused about where put alias in the function
parameters but of course it's in the first () meant to be used as
template parameters
More information about the Digitalmars-d-learn
mailing list