[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
;
}
- [lmi-commits] [lmi] master updated (dd6ee0a -> 8aa09b9), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 40218dc 03/14: Factor out commutation-function speed tests, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b8f43e0 06/14: Transpose several unit-test functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master e6ed669 01/14: Test guideline premium calculations with more complications, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b1eecea 02/14: Stabilize unit-test timing, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 28cabc2 04/14: Prefer lambdas to std::bind(),
Greg Chicares <=
- [lmi-commits] [lmi] master 61a04eb 08/14: Make commutation functions default constructible, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master df25463 12/14: Avoid operator new, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master b657767 13/14: Remove conditionals that serve no further purpose, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 23fe71f 11/14: Do away with an undesirable smart pointer [290], Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 485e19b 07/14: Favor the rule of zero, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 762056e 05/14: Prefer PETE's operator<<=() to assign(), Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master ed251fc 09/14: Test implicit special member functions, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master c2087ae 10/14: Update a comment, Greg Chicares, 2021/04/05
- [lmi-commits] [lmi] master 8aa09b9 14/14: Expunge some pointless defect markers [287], Greg Chicares, 2021/04/05