TypeFunction example: ImplictConvTargets

Stefan Koch uplink.coder at googlemail.com
Mon Oct 5 12:59:12 UTC 2020


On Monday, 5 October 2020 at 12:50:39 UTC, Andrei Alexandrescu 
wrote:
> On 10/5/20 7:44 AM, Stefan Koch wrote:
>> Hi,
>> 
>> I've posted an incomplete version of a semantic translation of 
>> ImplictConvTargets from a template into a type function.
>> 
>> After a few rather trivial fixes let me show you what the code 
>> looks like now.
> [snip]
>
> The existing implementation is ancient (e.g. predates std.meta) 
> and certainly deserves a redoing with Filter, which turns it 
> into a 3-liner (untested):
>
> alias Integrals = AliasSeq!(byte, ubyte, short, ushort, int, 
> uint, long, ulong, CentTypeList, float, double, real, char, 
> wchar, dchar);
> alias convertsTo(U) = is(T : U);
> alias ImplicitConversionTargets(T) = Filter!(convertsTo, 
> Integrals);
>


Please post the complete version.
Which does not import the stdlib.
Thanks.


More information about the Digitalmars-d mailing list