From f2ba3cc18a4e36ff3e50300aa8e8d602f749a612 Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Fri, 28 Jan 2022 20:32:47 +0000 Subject: [PATCH] Use `in_range` for integer case --- src/core/include/units/magnitude.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 2fa89e3f..14682235 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -196,8 +196,7 @@ constexpr To checked_static_cast(From x) { // This function should only ever be called at compile time. The purpose of these exceptions is // to produce compiler errors, because we cannot `static_assert` on function arguments. if constexpr (std::is_integral_v) { - if (std::cmp_less(x, std::numeric_limits::min()) || - std::cmp_greater(x, std::numeric_limits::max())) { + if (!std::in_range(x)) { throw std::invalid_argument{"Cannot represent magnitude in this type"}; } } else {