Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 26_numerics / random / independent_bits_engine / cons / 55215.cc
blob1a418fb2904ef5ef61ed82540167741d77416bdc
1 // { dg-options "-std=gnu++11" }
2 // { dg-require-cstdint "" }
3 //
4 // Copyright (C) 2012-2013 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <random>
22 #include <testsuite_hooks.h>
24 int f(int x)
26 std::seed_seq sq(&x, &x + 1);
27 auto rnd = std::independent_bits_engine<std::mt19937, 9,
28 std::uint_fast32_t>(sq);
29 return std::uniform_int_distribution<int>()(rnd);
32 int g(int x)
34 std::seed_seq sq(&x, &x + 1);
35 auto rnd = std::independent_bits_engine<std::mt19937, 9,
36 std::uint_fast32_t>();
37 rnd.seed(sq);
38 return std::uniform_int_distribution<int>()(rnd);
41 void test01()
43 bool test __attribute__((unused)) = true;
45 const int f1 = f(0);
46 const int f2 = f(0);
48 const int g1 = g(0);
49 const int g2 = g(0);
51 VERIFY( f1 == f2 );
52 VERIFY( g1 == g2 );
53 VERIFY( f1 == g1 );
56 int main()
58 test01();
59 return 0;