parent
5015c666f0
commit
e061cc1415
1 changed files with 2 additions and 20 deletions
|
@ -15,27 +15,13 @@
|
|||
/* This file selects a seed source -- "nondeterministic" random number
|
||||
generator in boost documentation. It should be a wrapper for
|
||||
boost::random_device on platforms where this is available, otherwise
|
||||
it should most likely be the system time.
|
||||
it should most likely be the system time. (Currently boost::random_device
|
||||
is available on all supported platforms.)
|
||||
*/
|
||||
|
||||
#include "seed_rng.hpp"
|
||||
|
||||
/*****
|
||||
Use preprocessor tests to decide whether to try to include and
|
||||
use boost random device, or fallback to system time.
|
||||
*****/
|
||||
|
||||
#define SEED_RNG_USE_BOOST_RANDOM_DEVICE
|
||||
|
||||
/*****
|
||||
End preprocessor checks
|
||||
*****/
|
||||
|
||||
#ifdef SEED_RNG_USE_BOOST_RANDOM_DEVICE
|
||||
#include <boost/nondet_random.hpp>
|
||||
#else
|
||||
#include <ctime>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
@ -43,12 +29,8 @@
|
|||
namespace seed_rng {
|
||||
|
||||
uint32_t next_seed() {
|
||||
#ifdef SEED_RNG_USE_BOOST_RANDOM_DEVICE
|
||||
static boost::random_device rnd_;
|
||||
return rnd_();
|
||||
#else
|
||||
return static_cast<uint32_t> (std::time(0));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string next_seed_str() {
|
||||
|
|
Loading…
Add table
Reference in a new issue