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 n, size_t m, size_t r,
13 // UIntType a, size_t u, UIntType d, size_t s,
14 // UIntType b, size_t t, UIntType c, size_t l, UIntType f>
15 // class mersenne_twister_engine;
16
17 // template <class charT, class traits,
18 // class UIntType, size_t w, size_t n, size_t m, size_t r,
19 // UIntType a, size_t u, UIntType d, size_t s,
20 // UIntType b, size_t t, UIntType c, size_t l, UIntType f>
21 // basic_ostream<charT, traits>&
22 // operator<<(basic_ostream<charT, traits>& os,
23 // const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
24 //
25 // template <class charT, class traits,
26 // class UIntType, size_t w, size_t n, size_t m, size_t r,
27 // UIntType a, size_t u, UIntType d, size_t s,
28 // UIntType b, size_t t, UIntType c, size_t l, UIntType f>
29 // basic_ostream<charT, traits>&
30 // operator>>(basic_istream<charT, traits>& is,
31 // mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
32
33 #include <random>
34 #include <sstream>
35 #include <cassert>
36
37 void
test1()38 test1()
39 {
40 typedef std::mt19937 E;
41 E e1;
42 e1.discard(100);
43 std::ostringstream os;
44 os << e1;
45 std::istringstream is(os.str());
46 E e2;
47 is >> e2;
48 assert(e1 == e2);
49 }
50
51 void
test2()52 test2()
53 {
54 typedef std::mt19937_64 E;
55 E e1;
56 e1.discard(100);
57 std::ostringstream os;
58 os << e1;
59 std::istringstream is(os.str());
60 E e2;
61 is >> e2;
62 assert(e1 == e2);
63 }
64
main()65 int main()
66 {
67 test1();
68 test2();
69 }
70