lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 62aa27e 2/4: Replace a function object with a


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 62aa27e 2/4: Replace a function object with a lambda
Date: Wed, 14 Jul 2021 09:28:14 -0400 (EDT)

branch: master
commit 62aa27e4b27da9522c834ac5fc24fdfb823b92f9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Replace a function object with a lambda
---
 math_functions.hpp      | 17 +----------------
 math_functions_test.cpp | 17 -----------------
 2 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/math_functions.hpp b/math_functions.hpp
index f6559ef..fbedb7f 100644
--- a/math_functions.hpp
+++ b/math_functions.hpp
@@ -57,21 +57,6 @@ std::vector<T>& back_sum(std::vector<T>& v)
 // std::binary_function would have provided, because they're still
 // required for std::binder1st() or std::binder2nd(), or for PETE.
 
-namespace detail
-{
-/// Arithmetic mean; used only by assign_midpoint().
-
-template<typename T>
-struct mean
-{
-    using first_argument_type  = T;
-    using second_argument_type = T;
-    using result_type          = T;
-    T operator()(T const& x, T const& y) const
-        {return std::midpoint(x, y);}
-};
-} // namespace detail
-
 /// Divide integers, rounding away from zero.
 ///
 /// This floating-point analogue may be useful for cross checking:
@@ -355,7 +340,7 @@ void assign_midpoint
         ,in_0.end()
         ,in_1.begin()
         ,out.begin()
-        ,detail::mean<double>()
+        ,[=](T t0, T t1) {return std::midpoint(t0, t1);}
         );
 }
 
diff --git a/math_functions_test.cpp b/math_functions_test.cpp
index eafd7c2..dc0ee55 100644
--- a/math_functions_test.cpp
+++ b/math_functions_test.cpp
@@ -327,23 +327,6 @@ void test_signum(char const* file, int line)
 
 int test_main(int, char*[])
 {
-    double      smallnumD = std::numeric_limits<double     >::min();
-    double      bignumD   = std::numeric_limits<double     >::max();
-
-    long double smallnumL = std::numeric_limits<long double>::min();
-    long double bignumL   = std::numeric_limits<long double>::max();
-
-    // Test detail::mean<>(). This is pointless as long as
-    // std::midpoint() is correctly implemented.
-
-    LMI_TEST_EQUAL(1.5, detail::mean<double>()(1.0, 2.0));
-    LMI_TEST_EQUAL(smallnumD, detail::mean<double>()(smallnumD, smallnumD));
-    LMI_TEST_EQUAL(bignumD  , detail::mean<double>()(bignumD  , bignumD  ));
-
-    LMI_TEST_EQUAL(1.5, detail::mean<long double>()(1.0, 2.0));
-    LMI_TEST_EQUAL(smallnumL, detail::mean<long 
double>()(smallnumL,smallnumL));
-    LMI_TEST_EQUAL(bignumL  , detail::mean<long double>()(bignumL  ,bignumL  
));
-
     // Test assign_midpoint().
 
     constexpr double smallnum = std::numeric_limits<double>::min();



reply via email to

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