1 #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
2 #define BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
4 // Copyright 2017 Peter Dimov
6 // Distributed under the Boost Software License, Version 1.0.
8 // An implementation of minstd_rand that does not require
11 #include <boost/cstdint.hpp>
22 boost::uint_least32_t x_;
24 enum { a = 48271, m = 2147483647 };
28 minstd_rand(): x_( 1 )
32 explicit minstd_rand( boost::uint_least32_t x ): x_( x % m )
40 boost::uint_least32_t operator()()
42 boost::uint_least64_t y = x_;
46 x_ = static_cast<boost::uint_least32_t>( y );
55 #endif // #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED