mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Add full set of constraints to random integral generator
Related to #2433
This commit is contained in:
parent
9e445930cc
commit
4142e699c2
@ -65,12 +65,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Ideally this would be also constrained against the various char types,
|
||||
// but I don't expect users to run into that in practice.
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value,
|
||||
GeneratorWrapper<T>>
|
||||
std::enable_if_t<std::is_integral<T>::value, GeneratorWrapper<T>>
|
||||
random(T a, T b) {
|
||||
static_assert(
|
||||
!std::is_same<T, char>::value &&
|
||||
!std::is_same<T, uint8_t>::value &&
|
||||
!std::is_same<T, uint8_t>::value &&
|
||||
!std::is_same<T, signed char>::value &&
|
||||
!std::is_same<T, unsigned char>::value &&
|
||||
!std::is_same<T, bool>::value,
|
||||
"The requested type is not supported by the underlying random distributions from std" );
|
||||
return GeneratorWrapper<T>(
|
||||
Catch::Detail::make_unique<RandomIntegerGenerator<T>>(a, b, Detail::getSeed())
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user