util: use C++11 <random> instead of Boost.Random
Change-Id: Id0100a5ef14236f7e1d1f181af233e44bde3c1a2
Refs: #3599
diff --git a/src/util/random.cpp b/src/util/random.cpp
index a16d587..41775e4 100644
--- a/src/util/random.cpp
+++ b/src/util/random.cpp
@@ -19,20 +19,14 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#include "common.hpp"
-
#include "random.hpp"
#include "../security/detail/openssl.hpp"
-#include <boost/nondet_random.hpp>
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_int_distribution.hpp>
+#include <random>
namespace ndn {
namespace random {
-// OpenSSL-based (secure) pseudo-randomness generators
-
uint32_t
generateSecureWord32()
{
@@ -58,31 +52,26 @@
}
}
-// Boost.Random-based (simple) random generators
-
-static boost::random::mt19937&
+static std::mt19937&
getRandomGenerator()
{
- static boost::random_device randomSeedGenerator;
- static boost::random::mt19937 gen(randomSeedGenerator);
-
- return gen;
+ static std::mt19937 rng{std::random_device{}()};
+ return rng;
}
uint32_t
generateWord32()
{
- static boost::random::uniform_int_distribution<uint32_t> distribution;
+ static std::uniform_int_distribution<uint32_t> distribution;
return distribution(getRandomGenerator());
}
uint64_t
generateWord64()
{
- static boost::random::uniform_int_distribution<uint64_t> distribution;
+ static std::uniform_int_distribution<uint64_t> distribution;
return distribution(getRandomGenerator());
}
-
} // namespace random
} // namespace ndn