Type functions with std.algorithm

Stefan Koch uplink.coder at googlemail.com
Sun Oct 11 00:46:37 UTC 2020


The code below here works with the current talias_master branch!

alias type = __type;

type[] makeTypeArray(type[] types ...)
{
     return types;
}

import std.algorithm;

enum type[] types = makeTypeArray(int, uint, long, ulong);
enum size4 = types.filter!((type a) { return a.sizeof == 4; } );
pragma(msg, () {
     type[] result = [];
     foreach(t;size4)
     {
         result ~= t;
     }
     return result;
}().tupleof);
// outputs: tuple((int), (uint))


More information about the Digitalmars-d mailing list