私は特定の引数でのみ有効なmixinテンプレートを持っています。引数が無効な場合、エラーメッセージでコンパイルを停止したい。テンプレートの場合はassert(false, "Invalid args for Yoo")
を使用しますが、これはmixinテンプレートでは機能しません。下の例のコンパイルを停止するには?mixinテンプレート:コンパイルを中断する方法は?
mixin template Yoo(args...) {
static if (args.length == 0) {
pragma(msg, "Invalid args! (how to halt the compilation?)");
} else {
pragma(msg, "Valid args:", args);
}
}
void main() {
mixin Yoo;
mixin Yoo!(1,2,3);
}