The file boost/random/uniform_int_distribution.hpp was introduced in boost

version 1.47. If we have older Boost, use random numbers from libc.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This commit is contained in:
Joe Thornber 2015-01-16 10:19:25 +00:00
parent 50341faa64
commit ef517035f1

View File

@ -5,8 +5,16 @@
#include "persistent-data/data-structures/array_block.h"
#include "test_utils.h"
#include <boost/version.hpp>
#if BOOST_VERSION >= 104700
#define HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
#endif
#include <boost/random/mersenne_twister.hpp>
#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
#include <boost/random/uniform_int_distribution.hpp>
#endif
#include <utility>
#include <deque>
#include <vector>
@ -40,10 +48,16 @@ namespace {
using namespace boost::random;
#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
boost::random::uniform_int_distribution<uint64_t> uniform_dist(0, max);
#endif
while (r.size() < count) {
#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
block_address b = uniform_dist(rng_);
#else
block_address b = random() % max;
#endif
r.insert(b);
}
@ -75,7 +89,9 @@ namespace {
space_map::ptr sm_;
transaction_manager tm_;
#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
boost::random::mt19937 rng_;
#endif
};
}
@ -312,3 +328,4 @@ TEST_F(BloomFilterTests, false_positives_over_multiple_eras)
}
//----------------------------------------------------------------