1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <random>
10
11// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
12// UIntType a, size_t u, UIntType d, size_t s,
13// UIntType b, size_t t, UIntType c, size_t l, UIntType f>
14// class mersenne_twister_engine;
15
16// template<class Sseq> void seed(Sseq& q);
17
18#include <random>
19#include <cassert>
20
21#include "test_macros.h"
22
23void
24test1()
25{
26 unsigned a[] = {3, 5, 7};
27 std::seed_seq sseq(a, a+3);
28 std::mt19937 e1;
29 std::mt19937 e2(sseq);
30 assert(e1 != e2);
31 e1.seed(sseq);
32 assert(e1 == e2);
33}
34
35void
36test2()
37{
38 unsigned a[] = {3, 5, 7};
39 std::seed_seq sseq(a, a+3);
40 std::mt19937_64 e1;
41 std::mt19937_64 e2(sseq);
42 assert(e1 != e2);
43 e1.seed(q&: sseq);
44 assert(e1 == e2);
45}
46
47int main(int, char**)
48{
49 test1();
50 test2();
51
52 return 0;
53}
54

source code of libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp