hap.random.traits

Implements compile-time checks for different features of random number generating code.

License:
Boost License 1.0.

Authors:
Andrei Alexandrescu, Joseph Rushton Wakeling

Source:
hap/random/traits.d

template isUniformRNG(Range, ElementType)
template isUniformRNG(Range)
Test if Range is a uniform random number generator. The overload taking an ElementType also makes sure that the RNG generates values of that type.

A uniform random number generator has at least the following features:
  • it is an InputRange
  • it has a bool isUniformRandom field readable in CTFE
  • its element type is a uniform integral type
  • it has min and max fields whose type is the same as the element type

This quite strict definition follows that in the C++11 standard. Note that the template is unable to enforce some required features, such as the requirement that the RNG's values must be drawn from the closed interval [min, max].

template isSeedable(UniformRNG, SeedType)
template isSeedable(UniformRNG)
Test if UniformRNG is a seedable uniform random number generator. The overload taking a SeedType also makes sure that the generator can be seeded with SeedType.

A seedable random-number generator has the following additional features:
  • it has a seed(ElementType) function

template isRandomDistribution(RandomDist, ElementType)
template isRandomDistribution(RandomDist)
Test if RandomDist is a random distribution. The overload taking an ElementType also makes sure that the distribution generates values of that type.

A random distribution has at least the following features:
  • it's an InputRange
  • it has a bool isRandomDistribution field readable in CTFE