diff options
| author | Martin Hořeňovský | 2022-06-02 12:15:29 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-06-02 12:15:35 +0200 |
| commit | 4142e699c2d970ee039bb1cfd406401f7d94393e (patch) | |
| tree | ab45770bf13b4847b37375e6fe9d266400c231f3 /src/catch2/generators | |
| parent | 9e445930cc22d2a80617b3198a7a260bc31c4ae4 (diff) | |
| download | catch3-4142e699c2d970ee039bb1cfd406401f7d94393e.tar.gz | |
Add full set of constraints to random integral generator
Related to #2433
Diffstat (limited to 'src/catch2/generators')
| -rw-r--r-- | src/catch2/generators/catch_generators_random.hpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/catch2/generators/catch_generators_random.hpp b/src/catch2/generators/catch_generators_random.hpp index 15043211..8b2c4949 100644 --- a/src/catch2/generators/catch_generators_random.hpp +++ b/src/catch2/generators/catch_generators_random.hpp @@ -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()) ); |