Reimplementing the bulk of std.meta iteratively

Atila Neves atila.neves at gmail.com
Thu Oct 8 10:05:10 UTC 2020


On Thursday, 8 October 2020 at 09:51:28 UTC, Stefan Koch wrote:
> On Thursday, 8 October 2020 at 09:44:33 UTC, Atila Neves wrote:
>> On Thursday, 1 October 2020 at 02:49:43 UTC, Stefan Koch wrote:
>>> [...]
>>
>> import std.algorithm: filter, equal;
>>
>> type[] types = [int, uint, long, ulong];
>> auto size4 = types.filter!(a => a.sizeof == 4);
>> assert(equal(size4, [int, uint]));
>>
>> No more std.meta.Filter.
>>
>>> [...]
>>
>> I can't see how that's the case.
>
> What you just described is what type functions do.
> The point that with first class type you could do also this:
>
> // cat type_list.txt: 'int, uint, long, ulong';
> auto type_txt = readText("type_list.txt");
> type[] types = type_txt.parseTypes()
> auto size4 = types.filter!(a => a.sizeof == 4);
> assert(equal(size4, [int, uint]));
> type[0] myVar1;
> type[1] myVar2;

There's no IO at compile-time.


More information about the Digitalmars-d mailing list