www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9419] New: std.random.uniform of BigInt

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

           Summary: std.random.uniform of BigInt
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-01-28 16:27:18 PST ---
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

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