I want to join file names and image formats at compile time.
The following example doesn't work, because string[]
can't be evaluated at compile I suppose...
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;
}
}
It fails with the error message:
Error: arithmetic/string type expected for value-parameter, not string[]
I need this to be finally fed into import()
. How can the error be resolved?