Bug 10882 – std.random.MersenneTwisterEngine.seed() fails if passed a static array

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-24T09:26:09Z
Last change time
2020-03-21T03:56:31Z
Assigned to
No Owner
Creator
Joseph Rushton Wakeling

Attachments

IDFilenameSummaryContent-TypeSize
1243mtseed.dExample code to illustrate the bug. Comment out last line and the program runs correctly.text/x-dsrc170

Comments

Comment #0 by joseph.wakeling — 2013-08-24T09:26:09Z
Created attachment 1243 Example code to illustrate the bug. Comment out last line and the program runs correctly. MersenneTwisterEngine can take as seed either a single unsigned integer or a range of 624 unsigned integers. However, if a static array uint[624] is passed to it, it fails with the following error: ---------------------------------------------- Error: template std.random.MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18).MersenneTwisterEngine.seed does not match any function template declaration. Candidates are: /opt/dmd/include/d2/std/random.d(574): std.random.MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18).MersenneTwisterEngine.seed()(UIntType value = defaultSeed) /opt/dmd/include/d2/std/random.d(613): std.random.MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18).MersenneTwisterEngine.seed(T)(T range) if (isInputRange!T && is(Unqual!(ElementType!T) == UIntType)) mtseed.d(10): Error: template std.random.MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18).MersenneTwisterEngine.seed()(UIntType value = defaultSeed) cannot deduce template function from argument types !()(uint[624LU]) ---------------------------------------------- The attached test code illustrates the problem, with Mt19937 accepting a dynamic array of length 624 as seed, but not a static array of equal length.
Comment #1 by b2.temp — 2016-01-23T09:57:31Z
A static array is not an input range, it can't be consumed. The constaint in see() clearly only takes input ranges.