-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cxx
33 lines (25 loc) · 868 Bytes
/
example.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <random>
#include "statelessrnd.hpp"
int main() {
using namespace statelessrnd;
constexpr auto rnd = minstd_rand::seed(42u);
constexpr auto rnd2 = rnd.next();
std::cout << *rnd << '\n';
std::cout << *rnd2 << '\n';
constexpr auto a = *rnd;
constexpr auto b = rnd.value();
constexpr decltype(rnd)::value_type c{rnd};
static_assert(a == b && a == c);
constexpr auto seed = minstd_rand::seed(42u, false);
static_assert(*seed == 42u);
constexpr auto rnd3 = seed.next().next().next();
static_assert(minstd_rand::seed(*rnd3).value() == rnd3.next().value());
auto stlrnd = std::minstd_rand(*seed);
stlrnd.discard(100);
std::cout << stlrnd() << '\n';
std::cout << seed.discard(101).value() << '\n';
std::cout << minstd_rand::seed(stlrnd()).value() << '\n';
std::cout << stlrnd() << '\n';
return 0;
}