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. eponymoustemplate isUniformRNG(Rng, ElementType)
    enum isUniformRNG (
    Rng
    ElementType
    )
  2. eponymoustemplate 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