isUniformRNG

Test if Rng is a random-number generator. The overload taking a ElementType also makes sure that the Rng generates values of that type.

A random-number generator has at least the following features:

  • it's an InputRange
  • it has a 'bool isUniformRandom' field readable in CTFE
  1. template isUniformRNG(Rng, ElementType)
    template isUniformRNG (
    Rng
    ElementType
    ) {
    enum bool isUniformRNG;
    }
  2. template isUniformRNG(Rng)

Examples

1 struct NoRng
2 {
3     @property uint front() {return 0;}
4     @property bool empty() {return false;}
5     void popFront() {}
6 }
7 static assert(!isUniformRNG!(NoRng));
8 
9 struct validRng
10 {
11     @property uint front() {return 0;}
12     @property bool empty() {return false;}
13     void popFront() {}
14 
15     enum isUniformRandom = true;
16 }
17 static assert(isUniformRNG!(validRng, uint));
18 static assert(isUniformRNG!(validRng));

Meta

Suggestion Box / Bug Report