[Issue 9339] New: std.random.uniform!Enum should return random enum member
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 17 14:33:58 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9339
Summary: std.random.uniform!Enum should return random enum
member
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: hsteoh at quickfur.ath.cx
--- Comment #0 from hsteoh at quickfur.ath.cx 2013-01-17 14:33:56 PST ---
Currently, std.random.uniform does not respect enum bounds:
import std.random;
import std.stdio;
enum Fruit {
Apple = 14,
Orange = 27,
Pear = 36,
Mango = 47
}
void main() {
writefln("%d", Fruit.min);
writefln("%d", Fruit.max);
writeln(uniform!Fruit());
}
Typical output:
14
47
cast(Fruit)-2046817621
It should at the very least respect the enum range defined by the enum's .min
and .max properties (which in this case are 14 and 47, respectively).
Ideally, it should only return one of the four possible values of Fruit, not
anything outside the range of .min and .max, and not anything in between the
four possible values.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list