First life-signs of type functions

Nick Treleaven nick at geany.org
Wed May 13 19:22:36 UTC 2020


On Sunday, 10 May 2020 at 08:39:42 UTC, Nick Treleaven wrote:
> bool anySatisfy(alias Tem, alias[] S)
> {
>     bool found;
>     alias E;
>     while (S.length)
>     {
>         E = S[0];
>         if (Tem!E)
>             return true;
>         S = S[1..$];
>     }
>     return false;
> }

I realized after posting that Tem!E can't work, because the type 
function must be compiled before evaluating E. Tem!E would be a 
constant expression, if it even compiles (e.g. passing E as a 
template alias parameter, not passing the value of E).

So as Stefan wrote, type functions are like CTFE functions (maybe 
a superset?).


More information about the Digitalmars-d mailing list