lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 5a157a2 1/5: Rename variables: std::numeric_l


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 5a157a2 1/5: Rename variables: std::numeric_limits means traits, not just limits
Date: Thu, 13 Apr 2017 06:58:29 -0400 (EDT)

branch: master
commit 5a157a23244db91577e86e99bfe3bc285416557d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Rename variables: std::numeric_limits means traits, not just limits
    
    std::numeric_limits was probably conceived as an encapsulation of
    DBL_MAX, INT_MIN, etc.; but most of its members are not limits at all,
    so it is best to use "traits" in local names throughout this code.
---
 bourn_cast_test.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/bourn_cast_test.cpp b/bourn_cast_test.cpp
index 344365b..1407407 100644
--- a/bourn_cast_test.cpp
+++ b/bourn_cast_test.cpp
@@ -61,14 +61,14 @@ inline To bourn_cast(From from)
 template<typename T>
 void test_same(char const* file, int line)
 {
-    using limits = std::numeric_limits<T>;
-    T upper = limits::max();
-    T lower = limits::lowest();
+    using traits = std::numeric_limits<T>;
+    T upper = traits::max();
+    T lower = traits::lowest();
     INVOKE_BOOST_TEST_EQUAL(upper, bourn_cast<T>(upper), file, line);
     INVOKE_BOOST_TEST_EQUAL(T( 1), bourn_cast<T>(T( 1)), file, line);
     INVOKE_BOOST_TEST_EQUAL(T( 0), bourn_cast<T>(T( 0)), file, line);
     INVOKE_BOOST_TEST_EQUAL(lower, bourn_cast<T>(lower), file, line);
-    if(limits::is_signed)
+    if(traits::is_signed)
         {
         INVOKE_BOOST_TEST_EQUAL(T(-1), bourn_cast<T>(T(-1)), file, line);
         }
@@ -550,14 +550,14 @@ void test_m64_neighborhood()
 
 void test_boost_anomalies()
 {
-    using double_limits = std::numeric_limits<double>;
+    using double_traits = std::numeric_limits<double>;
 
     // IEEE 754-2008 [5.8, conversion to integer]: "When a NaN or infinite
     // operand cannot be represented in the destination format and this
     // cannot otherwise be indicated, the invalid operation exception shall
     // be signaled."
     BOOST_TEST_THROW
-        (bourn_cast<int>(double_limits::quiet_NaN())
+        (bourn_cast<int>(double_traits::quiet_NaN())
         ,std::runtime_error
         ,"Cannot cast NaN to integral."
         );
@@ -567,9 +567,9 @@ void test_boost_anomalies()
     // an infinity into the same infinity in another format."
     try
         {
-        bourn_cast<long double>(double_limits::infinity());
+        bourn_cast<long double>(double_traits::infinity());
         // That worked, so this should too...
-        bourn_cast<float>(double_limits::infinity());
+        bourn_cast<float>(double_traits::infinity());
         // ...because all infinities are convertible.
         BOOST_TEST(true);
         }



reply via email to

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