test144

Undocumented in source.
immutable
@TestInfo(&tester144, [HostSymbol("printStr", cast(void*)&external_print_string), HostSymbol("printInt", cast(void*)&external_print_i64_func)])
auto test144 = q{--- test144 // select function @extern(module, "host") void printStr(u8[]); @extern(module, "host") void printInt(i64 i); bool isInteger($type type) { return type == u8 || type == i8 || type == u16 || type == i16 || type == u32 || type == i32 || type == u64 || type == i64; } $alias selectPrintFunc($type T) { if (isInteger(T)) return printInt; if ($isSlice(T)) return printStr; $compileError("Invalid type"); } void run() { alias func1 = selectPrintFunc(u8[]); func1("Hello"); alias func2 = selectPrintFunc(i32); func2(42); } };

Meta