From cba9da3835747ea730d69e4bae5b27f50a653e87 Mon Sep 17 00:00:00 2001 From: monarch dodra Date: Wed, 22 Jan 2014 14:56:12 +0100 Subject: [PATCH] Move static asserts So they trigger before they create a compile error --- std/random.d | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/std/random.d b/std/random.d index e1ab7b2cf..60e6934fe 100644 --- a/std/random.d +++ b/std/random.d @@ -526,6 +526,11 @@ struct MersenneTwisterEngine(UIntType, size_t w, size_t n, size_t m, size_t r, UIntType c, size_t l) if(isUnsigned!UIntType) { + static assert(1 <= m && m <= n); + static assert(0 <= r && 0 <= u && 0 <= s && 0 <= t && 0 <= l); + static assert(r <= w && u <= w && s <= w && t <= w && l <= w); + static assert(0 <= a && 0 <= b && 0 <= c); + ///Mark this as a Rng enum bool isUniformRandom = true; @@ -549,15 +554,10 @@ Parameter for the generator. /// Largest generated value. enum UIntType max = w == UIntType.sizeof * 8 ? UIntType.max : (1u << w) - 1; + static assert(a <= max && b <= max && c <= max); /// The default seed value. enum UIntType defaultSeed = 5489u; - static assert(1 <= m && m <= n); - static assert(0 <= r && 0 <= u && 0 <= s && 0 <= t && 0 <= l); - static assert(r <= w && u <= w && s <= w && t <= w && l <= w); - static assert(0 <= a && 0 <= b && 0 <= c); - static assert(a <= max && b <= max && c <= max); - /** Constructs a MersenneTwisterEngine object. */