Before 2.0.72.0:
import std.algorithm : map, joiner;
import std.uni : toUpper;
import std.traits : EnumMembers;
import std.stdio : writeln;
import std.conv: to;
private enum Color : string {
RED = "red",
BLUE = "blue",
YELLOW = "yellow"
}
void main(string[] args) {
writeln( [ EnumMembers!Color ].map!( toUpper ).joiner( ", "
).to!string );
}
printed:
RED, BLUE, YELLOW
Now I got the following compiler error:
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\uni.d(8142,16): Error:
cannot implicitly convert expression (result.data()) of type string to Color
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\uni.d(9030,51): Error:
template instance std.uni.toCase!(toUpperIndex, 1051, toUpperTab, toUpper,
Color) error instantiating
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(593,19):
instantiated from here: toUpper!(Color)
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(488,16):
instantiated from here: MapResult!(toUpper, Color[])
source\enums\enums.d(24,35): instantiated from here:
map!(Color[])
source\enums\enums.d(24,58): Error: template
std.algorithm.iteration.joiner cannot deduce function from
argument types !()(MapResult!(toUpper, Color[]), string),
candidates are:
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(2050,6):
std.algorithm.iteration.joiner(RoR, Separator)(RoR r, Separator sep) if (isInputRange!RoR &&
isInputRange!(ElementType!RoR) && isForwardRange!Separator && is(ElementType!Separator
: ElementType!(ElementType!RoR)))
C:\develop\dmd-2.072.0\windows\bin\..\..\src\phobos\std\algorithm\iteration.d(2333,6):
std.algorithm.iteration.joiner(RoR)(RoR r) if (isInputRange!RoR &&
isInputRange!(ElementType!RoR))
dmd failed with exit code 1.
Any idea how to fix it?
Thanks,
Stefan