From ab19882e9424e10c42f341cc73e700ac57618270 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 12 Jul 2023 15:54:44 +0200 Subject: [PATCH] Codechange: hint in all branches of ClampTo to resolve compile-time (#11130) --- src/core/math_func.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index a9784dee51..c8916fb051 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -168,12 +168,12 @@ constexpr To ClampTo(From value) static_assert(std::numeric_limits::is_integer, "Do not clamp from non-integer values"); static_assert(std::numeric_limits::is_integer, "Do not clamp to non-integer values"); - if (sizeof(To) >= sizeof(From) && std::numeric_limits::is_signed == std::numeric_limits::is_signed) { + if constexpr (sizeof(To) >= sizeof(From) && std::numeric_limits::is_signed == std::numeric_limits::is_signed) { /* Same signedness and To type is larger or equal than From type, no clamping is required. */ return static_cast(value); } - if (sizeof(To) > sizeof(From) && std::numeric_limits::is_signed) { + if constexpr (sizeof(To) > sizeof(From) && std::numeric_limits::is_signed) { /* Signed destination and a larger To type, no clamping is required. */ return static_cast(value); }