[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5481] Refactor
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5481] Refactor |
Date: |
Sun, 03 Jun 2012 19:02:09 +0000 |
Revision: 5481
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5481
Author: chicares
Date: 2012-06-03 19:02:09 +0000 (Sun, 03 Jun 2012)
Log Message:
-----------
Refactor
Modified Paths:
--------------
lmi/trunk/numeric_io_traits.hpp
Modified: lmi/trunk/numeric_io_traits.hpp
===================================================================
--- lmi/trunk/numeric_io_traits.hpp 2012-06-03 18:29:28 UTC (rev 5480)
+++ lmi/trunk/numeric_io_traits.hpp 2012-06-03 19:02:09 UTC (rev 5481)
@@ -329,12 +329,6 @@
{return simplify_floating_point(s);}
};
-#if defined LMI_MSVCRT
-// COMPILER !! This workaround is rather poor, of course.
-inline float strtof(char const* nptr, char** endptr)
-{return std::strtod(nptr, endptr);}
-#endif // defined LMI_MSVCRT
-
template<> struct numeric_conversion_traits<float>
:public numeric_conversion_traits<Floating>
{
@@ -342,8 +336,8 @@
static int digits(T t) {return floating_point_decimals(t);}
static char const* fmt() {return "%#.*f";}
static T strtoT(char const* nptr, char** endptr)
- {
#if defined LMI_MSVCRT
+ {
// COMPILER !! This C runtime's strtod() doesn't support C99
"inf[inity]" nor
// "nan[(...)]" strings nor hexadecimal notation so provide our
// work around for at least the first one of them which we actually
@@ -358,9 +352,12 @@
}
return std::numeric_limits<T>::infinity();
}
-#endif // defined LMI_MSVCRT
- return strtof(nptr, endptr);
+ // This C runtime provides no strtof().
+ return std::strtod(nptr, endptr);
}
+#else // !defined LMI_MSVCRT
+ {return strtof(nptr, endptr);}
+#endif // !defined LMI_MSVCRT
};
template<> struct numeric_conversion_traits<double>
@@ -370,7 +367,6 @@
static int digits(T t) {return floating_point_decimals(t);}
static char const* fmt() {return "%#.*f";}
static T strtoT(char const* nptr, char** endptr)
- {
#if defined LMI_MSVCRT
// COMPILER !! This C runtime's strtod() doesn't support C99
"inf[inity]" nor
// "nan[(...)]" strings nor hexadecimal notation so provide our
@@ -378,6 +374,7 @@
// need. This workaround is, of course, incomplete as it doesn't
// even support "-inf" without mentioning long and non-lower-case
// versions or NaN support.
+ {
if(0 == std::strncmp(nptr, "inf", 3))
{
if(endptr)
@@ -386,17 +383,13 @@
}
return std::numeric_limits<T>::infinity();
}
-#endif // defined LMI_MSVCRT
return std::strtod(nptr, endptr);
}
+#else // !defined LMI_MSVCRT
+ {return std::strtod(nptr, endptr);}
+#endif // !defined LMI_MSVCRT
};
-#if defined LMI_MSVCRT
-// COMPILER !! This workaround is rather poor, of course.
-inline long double strtold(char const* nptr, char** endptr)
-{return std::strtod(nptr, endptr);}
-#endif // defined LMI_MSVCRT
-
template<> struct numeric_conversion_traits<long double>
:public numeric_conversion_traits<Floating>
{
@@ -410,7 +403,12 @@
static char const* fmt() {return "%#.*Lf";}
#endif // !defined LMI_MSVCRT
static T strtoT(char const* nptr, char** endptr)
+#if defined LMI_MSVCRT
+// This lacks the "INF" enhancements used for float and double...
+ {return std::strtod(nptr, endptr);}
+#else // !defined LMI_MSVCRT
{return strtold(nptr, endptr);}
+#endif // !defined LMI_MSVCRT
};
#endif // numeric_io_traits_hpp
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5481] Refactor,
Greg Chicares <=