Bug 9419 – std.random.uniform of BigInt

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-28T16:27:18Z
Last change time
2024-12-01T16:16:15Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#9949 →

Comments

Comment #0 by bearophile_hugs — 2013-01-28T16:27:18Z
In some situations I'd like to generate a random BigInt: import std.bigint: BigInt; import std.random: uniform; void main() { BigInt a = 0; BigInt b = BigInt(1) << 70; auto r = uniform(a, b); } Currently (DMD 2.062alpha) it gives: ...\dmd2\src\phobos\std\random.d(1106): Error: template std.random.uniform does not match any function template declaration. Candidates are: ...\dmd2\src\phobos\std\random.d(1104): std.random.uniform(string boundaries = "[)", T1, T2)(T1 a, T2 b) if (!is(CommonType!(T1, T2) == void)) ...\dmd2\src\phobos\std\random.d(1142): std.random.uniform(string boundaries = "[)", T1, T2, UniformRandomNumberGenerator)(T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isFloatingPoint!(CommonType!(T1, T2))) ...\dmd2\src\phobos\std\random.d(1175): std.random.uniform(string boundaries = "[)", T1, T2, UniformRandomNumberGenerator)(T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isIntegral!(CommonType!(T1, T2)) || isSomeChar!(CommonType!(T1, T2))) ...\dmd2\src\phobos\std\random.d(1255): std.random.uniform(T, UniformRandomNumberGenerator)(ref UniformRandomNumberGenerator urng) if (isIntegral!(T) || isSomeChar!(T)) ...\dmd2\src\phobos\std\random.d(1274): std.random.uniform(T)() if (isIntegral!(T) || isSomeChar!(T)) ...\dmd2\src\phobos\std\random.d(1106): ... (1 more, -v to show) ... ...\dmd2\src\phobos\std\random.d(1104): Error: template std.random.uniform cannot deduce template function from argument types !("[)",BigInt,BigInt,MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18))(BigInt,BigInt,MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18)) ...\dmd2\src\phobos\std\random.d(1106): Error: template instance uniform!("[)", BigInt, BigInt, MersenneTwisterEngine!(uint, 32, 624, 397, 31, 2567483615u, 11, 7, 2636928640u, 15, 4022730752u, 18)) errors instantiating template test.d(6): Error: template instance std.random.uniform!("[)", BigInt, BigInt) error instantiating
Comment #1 by robert.schadek — 2024-12-01T16:16:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9949 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB