TypeFunction example creatiing a conversion matrix

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 2 02:27:40 UTC 2020


On 10/1/20 5:22 PM, Walter Bright wrote:
> On 10/1/2020 2:04 PM, Walter Bright wrote:
>> Does the same thing, works today:
> 
> Yes, I see another message posted the same thing.

Separation of concerns applies to ctfe code as well. The function should 
just fetch the bool matrix. Formatting should not be mixed with that, 
but rather done later either at compile- or run-time:

auto makeConvMatrix(Ts...)() {
     bool[T.length[T.length] result;
     static foreach (i, T : Ts)
         static foreach (j, U : Ts)
             result[i][j] = is(T : U);
     return result;
}


More information about the Digitalmars-d mailing list