[Issue 9607] New: std.random.randomShuffle and partialShuffle don't work with Xorshift

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 27 04:34:47 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9607

           Summary: std.random.randomShuffle and partialShuffle don't work
                    with Xorshift
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-02-27 04:34:45 PST ---
import std.random: randomShuffle, rndGen, Mt19937,
                   Xorshift, partialShuffle;
void main() {
    int[] items = [10, 20, 30];
    randomShuffle(items); // OK
    randomShuffle(items, rndGen); // OK
    Mt19937 gen;
    randomShuffle(items, gen); // OK
    Xorshift rng;
    randomShuffle(items, rng); // Error.
    partialShuffle(items, 2, rng); // Error.
}



DMD 2.063alpha gives:


...\dmd2\src\phobos\std\random.d(1346): Error: constructor
std.random.XorshiftEngine!(uint, 128, 11, 8, 19).XorshiftEngine.this (uint x0)
is not callable using argument types (MersenneTwisterEngine!(uint, 32, 624,
397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18))
...\dmd2\src\phobos\std\random.d(1346): Error: cannot implicitly convert
expression (rndGen()) of type MersenneTwisterEngine!(uint, 32, 624, 397, 31,
2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18) to uint
...\dmd2\src\phobos\std\random.d(1376): Error: constructor
std.random.XorshiftEngine!(uint, 128, 11, 8, 19).XorshiftEngine.this (uint x0)
is not callable using argument types (MersenneTwisterEngine!(uint, 32, 624,
397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18))
...\dmd2\src\phobos\std\random.d(1376): Error: cannot implicitly convert
expression (rndGen()) of type MersenneTwisterEngine!(uint, 32, 624, 397, 31,
2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18) to uint
...\dmd2\src\phobos\std\random.d(1349): Error: template instance
std.random.partialShuffle!(int[], XorshiftEngine!(uint, 128, 11, 8, 19)) error
instantiating
temp3.d(10):        instantiated from here: randomShuffle!(int[],
XorshiftEngine!(uint, 128, 11, 8, 19))
temp3.d(10): Error: template instance std.random.randomShuffle!(int[],
XorshiftEngine!(uint, 128, 11, 8, 19)) error instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list