Experimental approach to reference-type random number generators
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Sat Aug 24 11:48:28 PDT 2013
On 24/08/13 20:35, Joseph Rushton Wakeling wrote:
> I do have one specific query
Actually, two. Lines 448-457 of the second codepad paste have this unittest,
with the last line commented out:
// Check .save works
foreach (Type; TypeTuple!(MinstdRand0, MinstdRand))
{
auto rnd1 = Type(unpredictableSeed);
auto rnd2 = rnd1.save;
//assert(rnd1 == rnd2);
// Enable next test when RNGs are reference types
version(none) { assert(rnd1 !is rnd2); }
//assert(rnd1.take(100).array() == rnd2.take(100).array());
}
If the last assert is uncommented,
assert(rnd1.take(100).array() == rnd2.take(100).array());
... then running the unittests results in the following error:
/opt/dmd/include/d2/std/array.d(37): Error: variable
std.array.array!(Take!(RandomGenerator!(LinearCongruentialEngine!(uint, 16807,
0, 2147483647)))).array.r has scoped destruction, cannot build closure
This is rather worrying and I'm concerned that this could be a fundamental flaw
in the whole design. Can anyone advise on how to fix it?
More information about the Digitalmars-d
mailing list