TypeFunction example creatiing a conversion matrix

Adam D. Ruppe destructionator at gmail.com
Fri Oct 2 03:38:37 UTC 2020


On Friday, 2 October 2020 at 02:21:03 UTC, Andrei Alexandrescu 
wrote:
>> template staticMap(alias F, Args...) {
>>      static foreach(ref Arg; Args)
>>          Arg = F!Arg;
>>      alias staticMap = Args;
>
> I don't get the interaction. How does mutating the argument 
> affect order of declaration?

Is typeof(Args[0]) in there the original arg or the mapped arg?

In a normal function, there's a distinct before-and-after that, 
in theory, doesn't exist outside functions (you can use stuff 
before they are lexically declared)... but even there, you cannot 
change the type of an already existing variable.

This would mean you can. Would certainly be strange.... but might 
work.


More information about the Digitalmars-d mailing list