isSeedable

Test if Rng is seedable. The overload taking a SeedType also makes sure that the Rng can be seeded with SeedType.

A seedable random-number generator has the following additional features:

  • it has a 'seed(ElementType)' function
  1. template isSeedable(Rng, SeedType)
    template isSeedable (
    Rng
    SeedType
    ) {
    enum bool isSeedable;
    }
  2. template isSeedable(Rng)

Examples

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

Meta

Suggestion Box / Bug Report