Codechange: hint in all branches of ClampTo to resolve compile-time (#11130)

This commit is contained in:
Patric Stout 2023-07-12 15:54:44 +02:00 committed by GitHub
parent 97138acc8a
commit ab19882e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,12 +168,12 @@ constexpr To ClampTo(From value)
static_assert(std::numeric_limits<To>::is_integer, "Do not clamp from non-integer values");
static_assert(std::numeric_limits<From>::is_integer, "Do not clamp to non-integer values");
if (sizeof(To) >= sizeof(From) && std::numeric_limits<To>::is_signed == std::numeric_limits<From>::is_signed) {
if constexpr (sizeof(To) >= sizeof(From) && std::numeric_limits<To>::is_signed == std::numeric_limits<From>::is_signed) {
/* Same signedness and To type is larger or equal than From type, no clamping is required. */
return static_cast<To>(value);
}
if (sizeof(To) > sizeof(From) && std::numeric_limits<To>::is_signed) {
if constexpr (sizeof(To) > sizeof(From) && std::numeric_limits<To>::is_signed) {
/* Signed destination and a larger To type, no clamping is required. */
return static_cast<To>(value);
}