[Issue 9339] std.random.uniform!Enum should return random enum member

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 18 10:20:11 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9339



--- Comment #14 from bearophile_hugs at eml.cc 2013-01-18 10:20:09 PST ---
(In reply to comment #6)

> > 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.

Then I don't understand. This ER asks for that function overload to return a
"random enum member". Isn't members[std.random.uniform(0, members.length)] a
random enum member?

And beside what the OP is asking, uniform() returns single random values of a
type. Isn't this what I am doing there?

-- 
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