Can not understand this code.

berni44 dlang at d-ecke.de
Fri Oct 25 09:05:32 UTC 2019


On Friday, 25 October 2019 at 06:40:19 UTC, lili wrote:
> Hi:
> What is the alias Min = xxx mean? why need defined a alias Min 
> in Min template?
> ```
> template Min(alias pred, Args...)
> if (Args.length > 0 && __traits(isTemplate, pred))
> {
>     static if (Args.length == 1)
>     {
>         alias Min = Alias!(Args[0]);
>     }
>     else static if (isLess!(pred, Args[1], Args[0]))
>     {
>         alias Min = Min!(pred, Args[1], Args[2 .. $]);
>     }
>     else
>     {
>         alias Min = Min!(pred, Args[0], Args[2 .. $]);
>     }
> }
>
> ```

I can't explain in detail, but I know, this is called an 
eponymous template.
See 
https://dlang.org/spec/template.html#implicit_template_properties


More information about the Digitalmars-d-learn mailing list