detail::randomize_rng<EngineT>();
}
-template <int min = 0,
- int max = std::numeric_limits<int>::max(),
- typename DistributionT = std::uniform_int_distribution<int>,
+template <typename IntegerT = int,
+ typename DistributionT = std::uniform_int_distribution<IntegerT>,
typename EngineT = std::default_random_engine>
-int generate_random_number()
+IntegerT generate_random_number()
{
- return detail::generate_random_number<int, DistributionT, EngineT>
- (min, max);
+ using limits = std::numeric_limits<IntegerT>;
+ return detail::generate_random_number<IntegerT, DistributionT, EngineT>
+ (limits::min(), limits::max());
}
template <typename IntegerT>
/* Technically, this can still collide and cause a false negative, but let's
be optimistic: */
if (std::numeric_limits<int>::max() > 32767) {
- ASSERT_GT(a, -1);
- ASSERT_GT(b, -1);
-
ASSERT_NE(a, b);
}
}
for (auto n = 100000; n; --n) {
constexpr int min = 0, max = 6;
- int a = ceph::util::generate_random_number<min, max>();
+ int a = ceph::util::generate_random_number(min, max);
ASSERT_GT(a, -1);
ASSERT_LT(a, 7);
}