aboutsummaryrefslogtreecommitdiff
path: root/absl/random/internal/mock_validators.h
diff options
context:
space:
mode:
authorJustin Bassett <jbassett@google.com>2024-05-21 16:56:45 -0700
committerCopybara-Service <copybara-worker@google.com>2024-05-21 16:57:23 -0700
commite7f1a950e97b805d634909124fa4c75b690d0475 (patch)
tree8d0c6417c27f468083cc36126da4282678607eaf /absl/random/internal/mock_validators.h
parenta2625a648dc69c5b3d0330f25004454716cacfc8 (diff)
downloadabseil-e7f1a950e97b805d634909124fa4c75b690d0475.tar.gz
abseil-e7f1a950e97b805d634909124fa4c75b690d0475.tar.bz2
abseil-e7f1a950e97b805d634909124fa4c75b690d0475.zip
Support int128/uint128 in validated MockingBitGen
`absl::int128` and `absl::uint128` are not `std::is_integral`. There is an internal `IsIntegral` type trait we could use, but it actually makes more sense to remove the `static_assert` altogether. Any compile-time validation should be done in `absl::Uniform` itself, and duplicating that logic here just increases the chance of divergence. PiperOrigin-RevId: 635971431 Change-Id: I9177ae64c86ee1abe6571e0b29aba1844553c972
Diffstat (limited to 'absl/random/internal/mock_validators.h')
-rw-r--r--absl/random/internal/mock_validators.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/absl/random/internal/mock_validators.h b/absl/random/internal/mock_validators.h
index 0ab2ee9b..d76d169c 100644
--- a/absl/random/internal/mock_validators.h
+++ b/absl/random/internal/mock_validators.h
@@ -31,6 +31,7 @@ namespace random_internal {
template <typename NumType>
class UniformDistributionValidator {
public:
+ // Handle absl::Uniform<NumType>(gen, absl::IntervalTag, lo, hi).
template <typename TagType>
static void Validate(NumType x, TagType tag, NumType lo, NumType hi) {
// For invalid ranges, absl::Uniform() simply returns one of the bounds.
@@ -39,17 +40,16 @@ class UniformDistributionValidator {
ValidateImpl(std::is_floating_point<NumType>{}, x, tag, lo, hi);
}
+ // Handle absl::Uniform<NumType>(gen, lo, hi).
static void Validate(NumType x, NumType lo, NumType hi) {
Validate(x, IntervalClosedOpenTag(), lo, hi);
}
- template <typename NumType_ = NumType>
+ // Handle absl::Uniform<NumType>(gen).
static void Validate(NumType) {
// absl::Uniform<NumType>(gen) spans the entire range of `NumType`, so any
- // value is okay.
- static_assert(std::is_integral<NumType_>{},
- "Non-integer types may have valid values outside of the full "
- "range (e.g. floating point NaN).");
+ // value is okay. This overload exists because the validation logic attempts
+ // to call it anyway rather than adding extra SFINAE.
}
private: