[Issue 9339] std.random.uniform!Enum should return random enum member
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 17 17:01:45 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9339
--- Comment #6 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-17 17:01:43 PST ---
(In reply to comment #4)
> (In reply to comment #1)
>
> > enum arr = [EnumMembers!T];
>
> Be very careful with enum arrays. They are very inefficient.
Well, the compiler is very inefficient, static will do.
> T uniform(T)()
> if (is(T == enum) && isIntegral!T || isSomeChar!T)
> {
> static immutable T[EnumMembers!T.length] members = [EnumMembers!T];
> return members[std.random.uniform(0, members.length)];
> }
That's not doing what was requested.
--
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