TypeFunction example creatiing a conversion matrix
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.com
Fri Oct 2 12:52:16 UTC 2020
On 10/2/20 6:51 AM, Stefan Koch wrote:
> On Friday, 2 October 2020 at 09:51:10 UTC, Walter Bright wrote:
>> On 10/1/2020 7:27 PM, Andrei Alexandrescu wrote:
>>> 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;
>>> }
>>
>> This piece of code may be useful in re-implementing std.meta.MostDerived.
>
> Doesn't seem like it.
> The code results in a parser error.
So many errors. Deficiency of copypasta strikes again.
auto makeConvMatrix(Ts...)() {
bool[Ts.length][Ts.length] result;
static foreach (i, T ; Ts)
static foreach (j, U ; Ts)
result[i][j] = is(T : U);
return result;
}
That won't really help much with MostDerived and friends - as Iain said,
for known types the conversions are well known.
More information about the Digitalmars-d
mailing list