blob: 28e00ec1eb88a77a96e25205c826808031768b10 [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 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);
Howard Hinnanta0eaf602010-08-22 00:42:21 +000024//
Howard Hinnant3e519522010-05-11 19:42:16 +000025// 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
37void
38test1()
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
51void
52test2()
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
65int main()
66{
67 test1();
68 test2();
69}