mirror of
https://github.com/dlang/phobos.git
synced 2025-05-08 20:19:43 +03:00
Move static asserts
So they trigger before they create a compile error
This commit is contained in:
parent
f680ea030f
commit
cba9da3835
1 changed files with 6 additions and 6 deletions
12
std/random.d
12
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)
|
UIntType c, size_t l)
|
||||||
if(isUnsigned!UIntType)
|
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
|
///Mark this as a Rng
|
||||||
enum bool isUniformRandom = true;
|
enum bool isUniformRandom = true;
|
||||||
|
|
||||||
|
@ -549,15 +554,10 @@ Parameter for the generator.
|
||||||
/// Largest generated value.
|
/// Largest generated value.
|
||||||
enum UIntType max =
|
enum UIntType max =
|
||||||
w == UIntType.sizeof * 8 ? UIntType.max : (1u << w) - 1;
|
w == UIntType.sizeof * 8 ? UIntType.max : (1u << w) - 1;
|
||||||
|
static assert(a <= max && b <= max && c <= max);
|
||||||
/// The default seed value.
|
/// The default seed value.
|
||||||
enum UIntType defaultSeed = 5489u;
|
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.
|
Constructs a MersenneTwisterEngine object.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue