1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <random>
11
12 // template<class UIntType, size_t w, size_t s, size_t r>
13 // class subtract_with_carry_engine
14 // {
15 // public:
16 // // types
17 // typedef UIntType result_type;
18 //
19 // // engine characteristics
20 // static constexpr size_t word_size = w;
21 // static constexpr size_t short_lag = s;
22 // static constexpr size_t long_lag = r;
23 // static constexpr result_type min() { return 0; }
24 // static constexpr result_type max() { return m-1; }
25 // static constexpr result_type default_seed = 19780503u;
26
27 #include <random>
28 #include <type_traits>
29 #include <cassert>
30
31 template <class _Tp>
where(const _Tp &)32 void where(const _Tp &) {}
33
34 void
test1()35 test1()
36 {
37 typedef std::ranlux24_base E;
38 static_assert((E::word_size == 24), "");
39 static_assert((E::short_lag == 10), "");
40 static_assert((E::long_lag == 24), "");
41 #if TEST_STD_VER >= 11
42 static_assert((E::min() == 0), "");
43 static_assert((E::max() == 0xFFFFFF), "");
44 #else
45 assert((E::min() == 0));
46 assert((E::max() == 0xFFFFFF));
47 #endif
48 static_assert((E::default_seed == 19780503u), "");
49 where(E::word_size);
50 where(E::short_lag);
51 where(E::long_lag);
52 where(E::default_seed);
53 }
54
55 void
test2()56 test2()
57 {
58 typedef std::ranlux48_base E;
59 static_assert((E::word_size == 48), "");
60 static_assert((E::short_lag == 5), "");
61 static_assert((E::long_lag == 12), "");
62 #if TEST_STD_VER >= 11
63 static_assert((E::min() == 0), "");
64 static_assert((E::max() == 0xFFFFFFFFFFFFull), "");
65 #else
66 assert((E::min() == 0));
67 assert((E::max() == 0xFFFFFFFFFFFFull));
68 #endif
69 static_assert((E::default_seed == 19780503u), "");
70 where(E::word_size);
71 where(E::short_lag);
72 where(E::long_lag);
73 where(E::default_seed);
74 }
75
main()76 int main()
77 {
78 test1();
79 test2();
80 }
81