The OpenD Programming Language

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

struct NoRng
{
    @property uint front() {return 0;}
    @property bool empty() {return false;}
    void popFront() {}
}
static assert(!isUniformRNG!(NoRng));

struct validRng
{
    @property uint front() {return 0;}
    @property bool empty() {return false;}
    void popFront() {}

    enum isUniformRandom = true;
}
static assert(isUniformRNG!(validRng, uint));
static assert(isUniformRNG!(validRng));

Meta