[PPL-devel] [GIT] ppl/ppl(master): Avoid use of constructors in numeric_limits.

Abramo Bagnara abramo.bagnara at gmail.com
Sun May 3 15:44:13 CEST 2009


Module: ppl/ppl
Branch: master
Commit: 333cc7aab97123abb0bae09c146bb9cad43ad6de
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=333cc7aab97123abb0bae09c146bb9cad43ad6de

Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date:   Sun May  3 15:45:56 2009 +0200

Avoid use of constructors in numeric_limits.

---

 src/checked_numeric_limits.hh |   56 ++++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/checked_numeric_limits.hh b/src/checked_numeric_limits.hh
index c6b0749..22786c6 100644
--- a/src/checked_numeric_limits.hh
+++ b/src/checked_numeric_limits.hh
@@ -44,27 +44,29 @@ template <typename Policy>						\
   static const bool has_quiet_NaN =  Policy::has_nan;                   \
                                                                         \
   static Type min() {							\
-    return Type(Checked::Extended_Int<Policy, T>::min,                  \
-                ROUND_NOT_NEEDED);                                      \
+    Type v;								\
+    v.raw_value() = Checked::Extended_Int<Policy, T>::min;		\
+    return v;								\
   }									\
                                                                         \
   static Type max() {							\
-    return Type(Checked::Extended_Int<Policy, T>::max,                  \
-                ROUND_NOT_NEEDED);                                      \
+    Type v;								\
+    v.raw_value() = Checked::Extended_Int<Policy, T>::max;		\
+    return v;								\
   }									\
 									\
   static Type infinity() {						\
-    return								\
-      Policy::has_infinity						\
-      ? PLUS_INFINITY                                                   \
-      : static_cast<Type>(0);						\
+    Type v;								\
+    Checked::assign_special<Policy>(v.raw_value(), VC_PLUS_INFINITY,	\
+			    ROUND_IGNORE);				\
+    return v;								\
   }									\
 									\
   static Type quiet_NaN() {						\
-    return								\
-      Policy::has_nan                                                   \
-      ? NOT_A_NUMBER                                                    \
-      : static_cast<Type>(0);						\
+    Type v;								\
+    Checked::assign_special<Policy>(v.raw_value(), VC_NAN,		\
+			    ROUND_IGNORE);				\
+    return v;								\
   }									\
 };
 
@@ -116,17 +118,16 @@ public:
   static const bool has_quiet_NaN =  Policy::has_nan;
 
   static Type infinity() {
-    return
-      Policy::has_infinity
-      ? PLUS_INFINITY
-      : static_cast<Type>(0);
+    Type v;
+    Checked::assign_special<Policy>(v.raw_value(), VC_PLUS_INFINITY,
+				    ROUND_IGNORE);
+    return v;
   }
 
   static Type quiet_NaN() {
-    return
-      Policy::has_nan
-      ? NOT_A_NUMBER
-      : static_cast<Type>(0);
+    Type v;
+    Checked::assign_special<Policy>(v.raw_value(), VC_NAN, ROUND_IGNORE);
+    return v;
   }
 };
 
@@ -145,17 +146,16 @@ public:
   static const bool has_quiet_NaN =  Policy::has_nan;
 
   static Type infinity() {
-    return
-      Policy::has_infinity
-      ? PLUS_INFINITY
-      : static_cast<Type>(0);
+    Type v;
+    Checked::assign_special<Policy>(v.raw_value(), VC_PLUS_INFINITY,
+				    ROUND_IGNORE);
+    return v;
   }
 
   static Type quiet_NaN() {
-    return
-      Policy::has_nan
-      ? NOT_A_NUMBER
-      : static_cast<Type>(0);
+    Type v;
+    Checked::assign_special<Policy>(v.raw_value(), VC_NAN, ROUND_IGNORE);
+    return v;
   }
 };
 




More information about the PPL-devel mailing list