On Sunday, 8 June 2014 at 13:55:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
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
Arguably, the issue is the difference between "invalid" and
downright "illegal" values. The thing about dchar is that while
it *can* have values higher than dchar max, it's (AFAIK) illegal
to have them, and the compiler (if it can) will flag you for it:
dchar c1 = 0x0000_D800; //Invalid, but fine.
dchar c2 = 0xFFFF_0000; //Illegal, nope.