d编译时构造器
原文
我想包含特定模块
时更改编译时数组,需要编译时
知道数组值.
你可这样:
static if (__traits(compiles, { import mymodule; }))
{
// 包含模块
enum compileTimeArray = ...;
}
else
{
// 不包含.
enum compileTimeArray = ...;
}
我认为__traits(compiles,...)
只检查表达式
是否语义正确
.
你是对的,这只检查模块
是否在编译时*可用*
.
要在构建系统
中检查!