dxorshift: random number generators from the extended Xorshift family
Joseph Rushton Wakeling via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sun May 15 07:49:16 PDT 2016
On Sunday, 15 May 2016 at 14:25:44 UTC, Basile B. wrote:
> The wrapper could be smaller with an alias this:
>
> [... snip ...]
>
> even if I'm not 100% sure if this is conform with previous
> version. At least the tests pass.
I'm surprised that one passes the test,
static assert(!isForwardRange!SafeRNG);
... ? Or did you only try the tests applied to the dxorshift
generators?
More generally: what I'd be worried about with this version is
that it readily re-opens the door to accidentally copying the
underlying RNG by value, if (as with Phobos RNGs) the postblit is
not disabled.
The wrapper I provided is more verbose, but it should guarantee
statistical safety in that respect.
I also have a personal bugbear about `alias this` inasmuch as the
current permissions constraints _force_ the exposure of
implementation details (i.e. the `getGen` method has to be
public), but that's more of a frustration than a serious worry in
this case ;-)
More information about the Digitalmars-d-announce
mailing list