http://d.puremagic.com/issues/show_bug.cgi?id=9339
Andrej Mitrovic <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Andrej Mitrovic <[email protected]> 2013-01-17 16:31:49 PST --- Would this suffice? auto uniform(T)() if (is(T == enum) && isIntegral!T || isSomeChar!T) { enum arr = [EnumMembers!T]; return randomSample(arr, 1); } (You would have to add a !is(T == enum) in the other template). Example: import std.random; import std.stdio; import std.traits; enum Fruit { Apple = 14, Orange = 27, Pear = 36, Mango = 47 } auto uniform(T)() if (is(T == enum) && isIntegral!T || isSomeChar!T) { enum arr = [EnumMembers!T]; return randomSample(arr, 1); } void main() { foreach (i; 0 .. 10) writeln(uniform!Fruit()); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
