changeset 11699:1e9ce581998e release-3-0-x

partial specialization for octave_int_fit_to_range
author John W. Eaton <jwe@octave.org>
date Tue, 18 Mar 2008 16:21:34 -0400
parents abe3831a5fc1
children a255ceb8e416
files liboctave/ChangeLog liboctave/oct-inttypes.h
diffstat 2 files changed, 8 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Tue Mar 18 15:39:43 2008 -0400
+++ b/liboctave/ChangeLog	Tue Mar 18 16:21:34 2008 -0400
@@ -5,8 +5,8 @@
 
 2008-03-18  John W. Eaton  <jwe@octave.org>
 
-	* oct-inttypes.h (OCTAVE_DBL_FTR): New macro.
-	Use it to provide double specializations for octave_int_fit_to_range.
+	* oct-inttypes.h (octave_int_fit_to_range):
+	Use partial specialization for double values.
 
 2008-03-12  John W. Eaton  <jwe@octave.org>
 
--- a/liboctave/oct-inttypes.h	Tue Mar 18 15:39:43 2008 -0400
+++ b/liboctave/oct-inttypes.h	Tue Mar 18 16:21:34 2008 -0400
@@ -128,26 +128,12 @@
   return (x > mx ? mx : (x < mn ? mn : T2 (x)));
 }
 
-#define OCTAVE_DBL_FTR(T) \
-  template <> \
-  inline T \
-  octave_int_fit_to_range<double, T> (const double& x, const T& mn, \
-				      const T& mx) \
-  { \
-    return (lo_ieee_isnan (x) ? 0 : (x > mx ? mx : (x < mn ? mn : static_cast<T> (x)))); \
-  }
-
-OCTAVE_DBL_FTR (char)
-OCTAVE_DBL_FTR (short)
-OCTAVE_DBL_FTR (int)
-OCTAVE_DBL_FTR (long)
-OCTAVE_DBL_FTR (long long)
-
-OCTAVE_DBL_FTR (unsigned char)
-OCTAVE_DBL_FTR (unsigned short)
-OCTAVE_DBL_FTR (unsigned int)
-OCTAVE_DBL_FTR (unsigned long)
-OCTAVE_DBL_FTR (unsigned long long)
+template <typename T>
+inline T
+octave_int_fit_to_range (const double& x, const T& mn, const T& mx)
+{
+  return (lo_ieee_isnan (x) ? 0 : (x > mx ? mx : (x < mn ? mn : static_cast<T> (x))));
+}
 
 // If X is unsigned and the new type is signed, then we only have to
 // check the upper limit, but we should cast the maximum value of the