From 4142e699c2d970ee039bb1cfd406401f7d94393e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 2 Jun 2022 12:15:29 +0200 Subject: [PATCH] Add full set of constraints to random integral generator Related to #2433 --- src/catch2/generators/catch_generators_random.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/catch2/generators/catch_generators_random.hpp b/src/catch2/generators/catch_generators_random.hpp index 1504321131..8b2c49498a 100644 --- a/src/catch2/generators/catch_generators_random.hpp +++ b/src/catch2/generators/catch_generators_random.hpp @@ -65,12 +65,17 @@ class RandomIntegerGenerator final : public IGenerator { } }; -// 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 -std::enable_if_t::value && !std::is_same::value, -GeneratorWrapper> +std::enable_if_t::value, GeneratorWrapper> random(T a, T b) { + static_assert( + !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value && + !std::is_same::value, + "The requested type is not supported by the underlying random distributions from std" ); return GeneratorWrapper( Catch::Detail::make_unique>(a, b, Detail::getSeed()) );