当前位置: 首页 > 工具软件 > Meta.Numerics > 使用案例 >

d利用std.meta

上官凯歌
2023-12-01
import std.meta;
alias Numerics = AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real, char, wchar, dchar);
enum convertsTo(T, U) = is(T : U);
alias ImplicitConversionTargets(T) = Filter!(ApplyLeft!(convertsTo, T), Numerics);

// 打印: (int, uint, long, ulong, float, double, real, dchar)
pragma(msg, ImplicitConversionTargets!int);
// 打印: (float, double, real)
pragma(msg, ImplicitConversionTargets!double);
 类似资料: