lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 28cabc2 04/14: Prefer lambdas to std::bind()


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 28cabc2 04/14: Prefer lambdas to std::bind()
Date: Mon, 5 Apr 2021 18:26:46 -0400 (EDT)

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

    Prefer lambdas to std::bind()
---
 commutation_functions_test.cpp | 43 ++++++++----------------------------------
 1 file changed, 8 insertions(+), 35 deletions(-)

diff --git a/commutation_functions_test.cpp b/commutation_functions_test.cpp
index 076ae89..573f7b0 100644
--- a/commutation_functions_test.cpp
+++ b/commutation_functions_test.cpp
@@ -32,7 +32,6 @@
 
 #include <algorithm>                    // max()
 #include <cmath>                        // fabs()
-#include <functional>                   // bind(), ref()
 #include <iomanip>                      // setw() etc.
 #include <ios>                          // ios_base::fixed()
 #include <vector>
@@ -688,41 +687,15 @@ void assay_speed()
 
     std::vector<double> reserve(q.size());
 
+    auto f0 = [&q, &ic]         {mete_olcf(q, ic);};
+    auto f1 = [&q, &ic, ig]     {mete_ulcf(q, ic, ig);};
+    auto f2 = [&ulcf, &reserve] {mete_reserve(ulcf, reserve);};
     std::cout
-        << "  Speed test: generate ordinary-life commutation functions\n    "
-        << TimeAnAliquot
-            (std::bind
-                (mete_olcf
-                ,q
-                ,ic
-                )
-            )
-        << '\n'
-        ;
-
-    std::cout
-        << "  Speed test: generate UL commutation functions\n    "
-        << TimeAnAliquot
-            (std::bind
-                (mete_ulcf
-                ,q
-                ,ic
-                ,ig
-                )
-            )
-        << '\n'
-        ;
-
-    std::cout
-        << "  Speed test: calculate yearly account values\n    "
-        << TimeAnAliquot
-            (std::bind
-                (mete_reserve
-                ,std::ref(ulcf)
-                ,reserve
-                )
-            )
-        << '\n'
+        << "\n  Speed tests..."
+        << "\n  olcf construct: " << TimeAnAliquot(f0)
+        << "\n  ulcf construct: " << TimeAnAliquot(f1)
+        << "\n  ulcf reserve  : " << TimeAnAliquot(f2)
+        << std::endl
         ;
 }
 



reply via email to

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