blob: 75716a43deae03c9c1b66bd89abcafc46df3ab45 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
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;
Howard Hinnanta0eaf602010-08-22 00:42:21 +000018//
Howard Hinnant3e519522010-05-11 19:42:16 +000019// // 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
Howard Hinnant16694b52012-12-12 21:14:28 +000031template <class _Tp>
32void where(const _Tp &) {}
33
Howard Hinnant3e519522010-05-11 19:42:16 +000034void
35test1()
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 /*static_*/assert((E::min() == 0)/*, ""*/);
42 /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
43 static_assert((E::default_seed == 19780503u), "");
Howard Hinnant16694b52012-12-12 21:14:28 +000044 where(E::word_size);
45 where(E::short_lag);
46 where(E::long_lag);
47 where(E::default_seed);
Howard Hinnant3e519522010-05-11 19:42:16 +000048}
49
50void
51test2()
52{
53 typedef std::ranlux48_base E;
54 static_assert((E::word_size == 48), "");
55 static_assert((E::short_lag == 5), "");
56 static_assert((E::long_lag == 12), "");
57 /*static_*/assert((E::min() == 0)/*, ""*/);
58 /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
59 static_assert((E::default_seed == 19780503u), "");
Howard Hinnant16694b52012-12-12 21:14:28 +000060 where(E::word_size);
61 where(E::short_lag);
62 where(E::long_lag);
63 where(E::default_seed);
Howard Hinnant3e519522010-05-11 19:42:16 +000064}
65
66int main()
67{
68 test1();
69 test2();
70}