default random object?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 15 11:07:54 PST 2009


Bill Baxter wrote:
> On Mon, Feb 16, 2009 at 3:51 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> auto b = uniform!("[]")(rng, byte.min, byte.max);
>>
>> Is this acceptable?
> 
> If that's what it took I'd probably try this instead:
> ubyte b = uniform(rng, 0,256);
> 
> And then add an explicit cast to ubyte if the compiler didn't like that.
> So no, I don't really think that's good enough.  Others may disagree
> about how important a use case this is, though.

This will indeed work:

ubyte b = cast(ubyte) uniform(rng, 0,256);

I just showed the solution involving no cast. So are you ok with that?


Andrei



More information about the Digitalmars-d mailing list