summaryrefslogtreecommitdiff
path: root/abseil-cpp/absl/random/poisson_distribution.h
diff options
context:
space:
mode:
Diffstat (limited to 'abseil-cpp/absl/random/poisson_distribution.h')
-rw-r--r--abseil-cpp/absl/random/poisson_distribution.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/abseil-cpp/absl/random/poisson_distribution.h b/abseil-cpp/absl/random/poisson_distribution.h
index cb5f5d5..f457308 100644
--- a/abseil-cpp/absl/random/poisson_distribution.h
+++ b/abseil-cpp/absl/random/poisson_distribution.h
@@ -26,6 +26,7 @@
#include "absl/random/internal/fastmath.h"
#include "absl/random/internal/generate_real.h"
#include "absl/random/internal/iostream_state_saver.h"
+#include "absl/random/internal/traits.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -80,7 +81,7 @@ class poisson_distribution {
double log_k_;
int split_;
- static_assert(std::is_integral<IntType>::value,
+ static_assert(random_internal::IsIntegral<IntType>::value,
"Class-template absl::poisson_distribution<> must be "
"parameterized using an integral type.");
};
@@ -133,7 +134,8 @@ template <typename IntType>
poisson_distribution<IntType>::param_type::param_type(double mean)
: mean_(mean), split_(0) {
assert(mean >= 0);
- assert(mean <= (std::numeric_limits<result_type>::max)());
+ assert(mean <=
+ static_cast<double>((std::numeric_limits<result_type>::max)()));
// As a defensive measure, avoid large values of the mean. The rejection
// algorithm used does not support very large values well. It my be worth
// changing algorithms to better deal with these cases.
@@ -222,8 +224,9 @@ poisson_distribution<IntType>::operator()(
// clang-format on
const double lhs = 2.0 * std::log(u) + p.log_k_ + s;
if (lhs < rhs) {
- return x > (max)() ? (max)()
- : static_cast<result_type>(x); // f(x)/k >= u^2
+ return x > static_cast<double>((max)())
+ ? (max)()
+ : static_cast<result_type>(x); // f(x)/k >= u^2
}
}
}