コンパイル時にファイル名と画像形式を結合したい。次の例は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()
。エラーはどのように解決できますか?