Interesting bug with std.random.uniform and dchar
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 8 06:54:11 PDT 2014
On Sun, Jun 08, 2014 at 11:17:41AM +0200, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
> On 08/06/14 11:02, monarch_dodra via Digitalmars-d-learn wrote:
> >Why would we ban uniform!T from accepting dchar? I see no reason for that.
> >
> >Let's just fix the bug by tweaking the internal check.
>
> Yea, I came to the same conclusion while working on it. :-)
>
> The solution I have is (i) in uniform!"[]" check that !is(ResultType
> == dchar) before checking the condition for calling
> uniform!ResultType, and (ii) inside uniform!T, place
>
> static if (is(T == dchar))
> {
> return uniform!"[]"(T.min, T.max, rng);
> }
Doesn't wchar need to have a similar specialization too? Aren't some
values of wchar invalid as well?
T
--
MS Windows: 64-bit rehash of 32-bit extensions and a graphical shell for
a 16-bit patch to an 8-bit operating system originally coded for a 4-bit
microprocessor, written by a 2-bit company that can't stand 1-bit of
competition.
More information about the Digitalmars-d-learn
mailing list