lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 63cc9f9e 3/5: Disable MSVC warning about nega


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 63cc9f9e 3/5: Disable MSVC warning about negating a value of unsigned type
Date: Tue, 14 Feb 2023 19:30:37 -0500 (EST)

branch: master
commit 63cc9f9e16152663ccc3d2f9710d9c92b31bcf78
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Disable MSVC warning about negating a value of unsigned type
    
    This warning is generally useful, but is unwanted here, so disable it
    locally.
---
 math_functions.hpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/math_functions.hpp b/math_functions.hpp
index d89f8226..5eda87fa 100644
--- a/math_functions.hpp
+++ b/math_functions.hpp
@@ -200,7 +200,18 @@ constexpr std::make_unsigned_t<T> u_abs(T t)
     static_assert(std::has_unique_object_representations_v<T>);
     static_assert(std::has_unique_object_representations_v<U>);
     U const u {static_cast<U>(t)};
+
+#if defined LMI_MSC
+#   pragma warning(push)
+    // unary minus operator applied to unsigned type, result still unsigned
+#   pragma warning(disable : 4146)
+#endif // defined LMI_MSC
+
     return (t < 0) ? static_cast<U>(-u) : u;
+
+#if defined LMI_MSC
+#   pragma warning(pop)
+#endif // defined LMI_MSC
 }
 
 // Actuarial functions.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]