2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_CORE_DETAIL_PCG_HPP
11 #define BOOST_BEAST_CORE_DETAIL_PCG_HPP
13 #include <boost/core/ignore_unused.hpp>
23 std::uint64_t state_ = 0;
24 std::uint64_t increment_;
27 using result_type = std::uint32_t;
29 // Initialize the generator.
30 // There are no restrictions on the input values.
35 // increment must be odd
36 increment_ = 2 * stream + 1;
37 boost::ignore_unused((*this)());
39 boost::ignore_unused((*this)());
45 std::uint64_t const p = state_;
47 6364136223846793005ULL +
49 std::uint32_t const x =
50 static_cast<std::uint32_t>(
51 ((p >> 18) ^ p) >> 27);
52 std::uint32_t const r = p >> 59;
56 return (x >> r) | (x << ((1 + ~r) & 31));