lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master f306a7d 2/2: Remove tests for C++11 features


From: Greg Chicares
Subject: [lmi-commits] [lmi] master f306a7d 2/2: Remove tests for C++11 features
Date: Thu, 27 Apr 2017 16:21:33 -0400 (EDT)

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

    Remove tests for C++11 features
    
    Code written in standard C++ should require no feature tests. Any
    toolchain that failed any of the removed tests is nonconforming.
---
 configure.ac | 51 ---------------------------------------------------
 round_to.hpp | 34 ----------------------------------
 2 files changed, 85 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1d12dfb..bcc117c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,57 +208,6 @@ if test "$profiling_option" = "yes"; then
     LDFLAGS="$LDFLAGS $PROFILING_FLAG"
 fi
 
-dnl === Checks for standard headers/functions ===
-
-AC_CHECK_HEADERS(curses.h)
-if test "$ac_cv_header_curses_h" != "yes"; then
-    AC_CHECK_HEADERS(conio.h)
-    if test "$ac_cv_header_conio_h" != "yes"; then
-        AC_MSG_FAILURE([Header for getch() not found: neither curses.h nor 
conio.h are available.])
-    fi
-fi
-
-dnl the functions below are typically found in libm and not libc so make sure
-dnl we look there
-AC_SEARCH_LIBS([log10l], [m],
-    [AC_DEFINE(HAVE_LOG10L, [1], [Define this if you have log10l function])]
-)
-AC_SEARCH_LIBS([fabsl], [m],
-    [AC_DEFINE(HAVE_FABSL, [1], [Define this if you have fabsl function])]
-)
-
-dnl check for snprintf: note that when compiling under gcc using -std= flag the
-dnl standard headers do not declare snprintf() and this is why we don't use
-dnl the usual AC_CHECK_FUNCS but reproduce the same workaround as used in
-dnl platform_dependent.hpp (see comment there) which makes it possible to
-dnl detect this function in all cases
-AC_CACHE_CHECK([for snprintf],
-    lmi_cv_func_snprintf,
-    [
-        AC_LINK_IFELSE([AC_LANG_PROGRAM(
-                [[
-                #if defined __GNUC__ && defined __STRICT_ANSI__
-                #   undef __STRICT_ANSI__
-                #endif
-                #include <stdio.h>]],
-                [[
-                char buf[1];
-                return snprintf(buf, 1, "%i", 0);
-                ]]
-            )],
-            lmi_cv_func_snprintf=yes,
-            lmi_cv_func_snprintf=no
-        )
-    ]
-)
-if test "x$lmi_cv_func_snprintf" = "xyes"; then
-    AC_DEFINE([HAVE_SNPRINTF], [1], [Define this if you have snprintf 
function])
-else
-    dnl TODO: for MSVC support we should check for _snprintf()
-    AC_MSG_FAILURE([The snprintf() function not found on your system])
-fi
-
-AM_CONDITIONAL(HAVE_SNPRINTF, [test "x$lmi_cv_func_snprintf" == "xyes"])
 AM_CONDITIONAL(LMI_WITH_CGI, [test "x$lmi_cgicc_option" == "xyes"])
 
 dnl === Library checks ===
diff --git a/round_to.hpp b/round_to.hpp
index 624b69d..e32810d 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -52,9 +52,6 @@
 // this alias-declaration to double.
 using max_prec_real = long double;
 
-// Any modern C++ compiler provides std::rint().
-#define LMI_HAVE_RINT
-
 namespace detail
 {
 #if 1
@@ -161,7 +158,6 @@ RealType round_not(RealType r)
 template<typename RealType>
 RealType round_up(RealType r)
 {
-#if defined LMI_HAVE_RINT
     RealType i_part = std::rint(r);
     if(i_part < r)
         {
@@ -172,32 +168,24 @@ RealType round_up(RealType r)
         i_part++;
         }
     return i_part;
-#else  // !defined LMI_HAVE_RINT
-    return std::ceil(r);
-#endif // !defined LMI_HAVE_RINT
 }
 
 // Round down.
 template<typename RealType>
 RealType round_down(RealType r)
 {
-#if defined LMI_HAVE_RINT
     RealType i_part = std::rint(r);
     if(r < i_part)
         {
         i_part--;
         }
     return i_part;
-#else  // !defined LMI_HAVE_RINT
-    return std::floor(r);
-#endif // !defined LMI_HAVE_RINT
 }
 
 // Truncate.
 template<typename RealType>
 RealType round_trunc(RealType r)
 {
-#if defined LMI_HAVE_RINT
     RealType i_part = std::rint(r);
     RealType f_part = r - i_part;
     // Consider the integer part 'i_part' and the fractional part
@@ -217,31 +205,13 @@ RealType round_trunc(RealType r)
         i_part++;
         }
     return i_part;
-#else  // !defined LMI_HAVE_RINT
-    RealType x = std::floor(std::fabs(r));
-    return (0.0 <= r) ? x : -x;
-#endif // !defined LMI_HAVE_RINT
 }
 
 // Round to nearest using bankers method.
 template<typename RealType>
 RealType round_near(RealType r)
 {
-#if defined LMI_HAVE_RINT
     RealType i_part = std::rint(r);
-#else  // !defined LMI_HAVE_RINT
-//  To return immediately with this value:
-//    return (RealType(0) < r) ? std::floor(r + 0.5) : std::ceil(r -0.5);
-//  would be incorrect, because halfway cases must be rounded to even.
-    RealType i_part =
-        (RealType(0) < r)
-            ? std::floor(r + 0.5)
-            : std::ceil (r - 0.5)
-            ;
-    // This 'i_part' needn't equal the value that std::rint() would
-    // return, as long as both produce the same correct result after
-    // adjustment below.
-#endif // !defined LMI_HAVE_RINT
     RealType f_part = r - i_part;
     RealType abs_f_part = std::fabs(f_part);
 
@@ -407,7 +377,6 @@ template<typename RealType>
 typename round_to<RealType>::rounding_fn_t
 round_to<RealType>::select_rounding_function(rounding_style const a_style) 
const
 {
-#if defined LMI_HAVE_RINT
     if
         (  a_style == default_rounding_style()
         && a_style != r_indeterminate
@@ -415,7 +384,6 @@ round_to<RealType>::select_rounding_function(rounding_style 
const a_style) const
         {
         return std::rint;
         }
-#endif // defined LMI_HAVE_RINT
 
     switch(a_style)
         {
@@ -450,7 +418,5 @@ round_to<RealType>::select_rounding_function(rounding_style 
const a_style) const
         }
 }
 
-#undef LMI_HAVE_RINT
-
 #endif // round_to_hpp
 



reply via email to

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