我想在编译时加入文件名和图像格式。以下示例不起作用,因为string[]
我想在编译时无法评估...
immutable imageFormats = ["bmp", "jpg", "gif", "png"];
template fileNamesWithImageFormat(string[] fileNames)
{
string[] fileNamesWithImageFormat() {
string[] ret;
ret.length = imageFormats.length * fileNames.length;
for (int j = 0; j < fileNames.length) {
for (int i = 0; i < imageFormats.length; ++i) {
ret[j * fileNames.length + i] = fileNames[j] ~ "." ~ imageFormats[i];
}
}
return ret;
}
}
它失败并显示错误消息:
Error: arithmetic/string type expected for value-parameter, not string[]
我需要将其最终输入import()
. 如何解决错误?