[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 924e3b3 1/2: Replace boost with std bind()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 924e3b3 1/2: Replace boost with std bind() |
Date: |
Sat, 21 Jan 2017 09:53:01 +0000 (UTC) |
branch: master
commit 924e3b3a5fdc445b40d3253d2f8152aed7a860e7
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Replace boost with std bind()
---
commutation_functions_test.cpp | 11 +++++------
expression_template_0_test.cpp | 14 ++++++--------
financial_test.cpp | 5 ++---
gpt_test.cpp | 2 +-
ihs_acctval.cpp | 12 +++++-------
input_realization.cpp | 9 ++++-----
input_test.cpp | 31 +++++++++++++++----------------
loads_test.cpp | 11 +++++------
main_cli.cpp | 4 ++--
obstruct_slicing_test.cpp | 5 ++---
timer.hpp | 4 ++--
timer_test.cpp | 5 ++---
vector_test.cpp | 2 +-
13 files changed, 52 insertions(+), 63 deletions(-)
diff --git a/commutation_functions_test.cpp b/commutation_functions_test.cpp
index e98c3c3..4493d8d 100644
--- a/commutation_functions_test.cpp
+++ b/commutation_functions_test.cpp
@@ -29,10 +29,9 @@
#include "test_tools.hpp"
#include "timer.hpp"
-#include <boost/bind.hpp>
-
#include <algorithm>
#include <cmath> // std::fabs()
+#include <functional> // std::bind()
#include <iomanip> // std::setw() etc.
#include <ios> // std::ios_base::fixed()
#include <numeric> // std::partial_sum()
@@ -685,7 +684,7 @@ void Test_1980_CSO_Male_ANB()
std::cout
<< " Speed test: generate ordinary-life commutation functions\n "
<< TimeAnAliquot
- (boost::bind
+ (std::bind
(mete_olcf
,q
,ic
@@ -697,7 +696,7 @@ void Test_1980_CSO_Male_ANB()
std::cout
<< " Speed test: generate UL commutation functions\n "
<< TimeAnAliquot
- (boost::bind
+ (std::bind
(mete_ulcf
,q
,ic
@@ -710,9 +709,9 @@ void Test_1980_CSO_Male_ANB()
std::cout
<< " Speed test: calculate yearly account values\n "
<< TimeAnAliquot
- (boost::bind
+ (std::bind
(mete_reserve
- ,boost::ref(ulcf)
+ ,std::ref(ulcf)
,reserve
)
)
diff --git a/expression_template_0_test.cpp b/expression_template_0_test.cpp
index ddb1de6..bf2cef5 100644
--- a/expression_template_0_test.cpp
+++ b/expression_template_0_test.cpp
@@ -42,14 +42,12 @@
#include "test_tools.hpp"
#include "timer.hpp"
-#include <boost/bind.hpp>
-
#if defined USE_UBLAS
# include <boost/numeric/ublas/vector.hpp>
#endif // defined USE_UBLAS
#include <algorithm>
-#include <functional>
+#include <functional> // std::bind() et al.
#include <iterator> // std::back_inserter()
#include <string>
#include <valarray>
@@ -82,7 +80,7 @@ struct greater_of
};
// Global variables for timing tests. It would be in better taste
- // to pass them as arguments, using boost::bind. However, that
+ // to pass them as arguments, using std::bind. However, that
// would rule out using some compilers (e.g., borland), and it's
// best to test this with as many different toolsets as possible.
@@ -206,12 +204,12 @@ void mete_stl_fancy()
,sv0b.end()
,sv1b.begin()
,tmp0.begin()
- ,boost::bind
+ ,std::bind
(std::minus<double>()
- ,_1
- ,boost::bind
+ ,std::placeholders::_1
+ ,std::bind
(std::multiplies<double>()
- ,_2
+ ,std::placeholders::_2
,2.1
)
)
diff --git a/financial_test.cpp b/financial_test.cpp
index 13c1ace..5d72bc6 100644
--- a/financial_test.cpp
+++ b/financial_test.cpp
@@ -26,9 +26,8 @@
#include "test_tools.hpp"
#include "timer.hpp"
-#include <boost/bind.hpp>
-
#include <cmath> // std::fabs()
+#include <functional> // std::bind()
#include <iomanip> // Formatting of optional detail.
#include <iostream>
#include <vector>
@@ -181,7 +180,7 @@ std::cout << "tolerance = .000005: " << .000005 << '\n';
<< decimals
<< " decimals\n "
<< TimeAnAliquot
- (boost::bind
+ (std::bind
(irr<VI,VI,VI>
,p.begin()
,p.end()
diff --git a/gpt_test.cpp b/gpt_test.cpp
index 5dcdb7c..6b19c3d 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -593,7 +593,7 @@ void gpt_test::mete_premiums()
/// Measure instantiation speed of old GPT class.
///
/// This simple pass-through function could have been written inline
-/// with boost::bind, but it's preferable not to drag that in.
+/// with std::bind, but it's preferable not to drag that in.
void gpt_test::mete_instantiate_old()
{
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 3d5cc46..0032062 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -46,11 +46,9 @@
#include "stratified_algorithms.hpp"
#include "surrchg_rates.hpp"
-#include <boost/bind.hpp>
-
#include <algorithm>
#include <cmath>
-#include <functional>
+#include <functional> // std::bind() et al.
#include <iterator> // std::back_inserter()
#include <limits>
#include <numeric>
@@ -1155,9 +1153,9 @@ void AccountValue::AddSurrChgLayer(int year, double
delta_specamt)
(SurrChgRates_->SpecamtRateDurationalFactor().begin()
,SurrChgRates_->SpecamtRateDurationalFactor().end() - year
,std::inserter(new_layer, new_layer.begin())
- ,boost::bind
+ ,std::bind
(round_surrender_charge()
- ,boost::bind(std::multiplies<double>(), _1, z)
+ ,std::bind(std::multiplies<double>(), std::placeholders::_1, z)
)
);
@@ -1188,9 +1186,9 @@ void AccountValue::ReduceSurrChg(int year, double
partial_surrchg)
(year + SurrChg_.begin()
, SurrChg_.end()
,year + SurrChg_.begin()
- ,boost::bind
+ ,std::bind
(round_surrender_charge()
- ,boost::bind(std::multiplies<double>(), _1, multiplier)
+ ,std::bind(std::multiplies<double>(), std::placeholders::_1,
multiplier)
)
);
}
diff --git a/input_realization.cpp b/input_realization.cpp
index 0098d1f..5291465 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -35,9 +35,8 @@
#include "round_to.hpp"
#include "value_cast.hpp"
-#include <boost/bind.hpp>
-
#include <algorithm>
+#include <functional> // std::bind()
#include <sstream>
#include <utility> // std::pair
@@ -544,10 +543,10 @@ std::string Input::RealizeDeathBenefitOption()
&& !std::is_sorted
(DeathBenefitOptionRealized_.begin()
,DeathBenefitOptionRealized_.end()
- ,boost::bind
+ ,std::bind
(std::logical_and<bool>()
- ,boost::bind(std::equal_to <mce_dbopt>(), _1,
mce_dbopt("B"))
- ,boost::bind(std::not_equal_to<mce_dbopt>(), _2,
mce_dbopt("B"))
+ ,std::bind(std::equal_to <mce_dbopt>(),
std::placeholders::_1, mce_dbopt("B"))
+ ,std::bind(std::not_equal_to<mce_dbopt>(),
std::placeholders::_2, mce_dbopt("B"))
)
)
)
diff --git a/input_test.cpp b/input_test.cpp
index 149a548..80beff2 100644
--- a/input_test.cpp
+++ b/input_test.cpp
@@ -41,8 +41,6 @@
#include "timer.hpp"
#include "xml_lmi.hpp"
-#include <boost/bind.hpp>
-
#include <xmlwrapp/document.h>
#if defined BOOST_MSVC || defined __BORLANDC__
@@ -50,6 +48,7 @@
#endif // defined BOOST_MSVC || defined __BORLANDC__
#include <cstdio> // std::remove()
#include <fstream>
+#include <functional> // std::bind()
#include <ios>
#include <string>
@@ -159,10 +158,10 @@ void input_test::test_product_database()
// writing individual functions by hand is simpler and clearer.
std::cout
<< "\n Database speed tests..."
- << "\n initialize() : " << TimeAnAliquot(boost::bind
(&product_database::initialize, &db, "sample" ))
- << "\n Query(vector) : " << TimeAnAliquot(boost::bind<void
>(&product_database::Query, &db, v, DB_MaturityAge))
- << "\n Query(scalar) : " <<
TimeAnAliquot(boost::bind<double>(&product_database::Query, &db,
DB_MaturityAge))
- << "\n entity_from_key() : " << TimeAnAliquot(boost::bind
(&product_database::entity_from_key, &db, DB_MaturityAge))
+ << "\n initialize() : " <<
TimeAnAliquot(std::bind(&product_database::initialize, &db, "sample"
))
+ << "\n Query(vector) : " << TimeAnAliquot(std::bind((void
(product_database::*)(std::vector<double>&, e_database_key)
const)&product_database::Query, &db, v, DB_MaturityAge))
+ << "\n Query(scalar) : " << TimeAnAliquot(std::bind((double
(product_database::*)(e_database_key) const)&product_database::Query,
&db, DB_MaturityAge))
+ << "\n entity_from_key() : " <<
TimeAnAliquot(std::bind(&product_database::entity_from_key, &db,
DB_MaturityAge))
<< '\n'
;
@@ -409,16 +408,16 @@ void input_test::assay_speed()
std::cout
<< "\n Class 'Input' speed tests..."
- << "\n Copy ctor: " << TimeAnAliquot(mete_copy_ctor )
- << "\n Assign : " << TimeAnAliquot(mete_assign_op )
- << "\n Equals : " << TimeAnAliquot(mete_equal_op )
- << "\n Overhead : " << TimeAnAliquot(mete_overhead )
- << "\n Read : " << TimeAnAliquot(boost::bind(mete_read, e))
- << "\n Write : " << TimeAnAliquot(mete_write )
- << "\n 'cns' io : " << TimeAnAliquot(mete_cns_io )
- << "\n 'ill' io : " << TimeAnAliquot(mete_ill_io )
- << "\n 'cns' xsd: " << TimeAnAliquot(mete_cns_xsd )
- << "\n 'ill' xsd: " << TimeAnAliquot(mete_ill_xsd )
+ << "\n Copy ctor: " << TimeAnAliquot(mete_copy_ctor )
+ << "\n Assign : " << TimeAnAliquot(mete_assign_op )
+ << "\n Equals : " << TimeAnAliquot(mete_equal_op )
+ << "\n Overhead : " << TimeAnAliquot(mete_overhead )
+ << "\n Read : " << TimeAnAliquot(std::bind(mete_read, e))
+ << "\n Write : " << TimeAnAliquot(mete_write )
+ << "\n 'cns' io : " << TimeAnAliquot(mete_cns_io )
+ << "\n 'ill' io : " << TimeAnAliquot(mete_ill_io )
+ << "\n 'cns' xsd: " << TimeAnAliquot(mete_cns_xsd )
+ << "\n 'ill' xsd: " << TimeAnAliquot(mete_ill_xsd )
<< '\n'
;
}
diff --git a/loads_test.cpp b/loads_test.cpp
index b5eda5a..826d3d9 100644
--- a/loads_test.cpp
+++ b/loads_test.cpp
@@ -30,9 +30,8 @@
#include "test_tools.hpp"
#include "timer.hpp"
-#include <boost/bind.hpp>
-
#include <cstddef> // std::size_t
+#include <functional> // std::bind()
namespace
{
@@ -230,25 +229,25 @@ int test_main(int, char*[])
std::cout
<< " Allocate: "
- << TimeAnAliquot(boost::bind(&LoadsTest::Allocate , &t))
+ << TimeAnAliquot(std::bind(&LoadsTest::Allocate , &t))
<< '\n'
;
std::cout
<< " Initialize: "
- << TimeAnAliquot(boost::bind(&LoadsTest::Initialize , &t))
+ << TimeAnAliquot(std::bind(&LoadsTest::Initialize , &t))
<< '\n'
;
std::cout
<< " Reinitialize: "
- << TimeAnAliquot(boost::bind(&LoadsTest::Reinitialize , &t))
+ << TimeAnAliquot(std::bind(&LoadsTest::Reinitialize , &t))
<< '\n'
;
std::cout
<< " Recalculate: "
- << TimeAnAliquot(boost::bind(&LoadsTest::Recalculate, &t))
+ << TimeAnAliquot(std::bind(&LoadsTest::Recalculate, &t))
<< '\n'
;
diff --git a/main_cli.cpp b/main_cli.cpp
index cb59d2d..79ef359 100644
--- a/main_cli.cpp
+++ b/main_cli.cpp
@@ -46,13 +46,13 @@
#include "timer.hpp"
#include "value_cast.hpp"
-#include <boost/bind.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/path.hpp>
#include <algorithm>
#include <cmath>
#include <cstdio> // std::printf()
+#include <functional> // std::bind()
#include <ios>
#include <iostream>
#include <ostream>
@@ -136,7 +136,7 @@ void self_test()
std::cout
<< "Test solve speed: "
- << TimeAnAliquot(boost::bind(z, "CLI_selftest", IP), 0.1)
+ << TimeAnAliquot(std::bind(z, "CLI_selftest", IP), 0.1)
<< '\n'
;
}
diff --git a/obstruct_slicing_test.cpp b/obstruct_slicing_test.cpp
index 0217bb2..39827be 100644
--- a/obstruct_slicing_test.cpp
+++ b/obstruct_slicing_test.cpp
@@ -26,8 +26,7 @@
#include "test_tools.hpp"
#include "timer.hpp"
-#include <boost/bind.hpp>
-
+#include <functional> // std::bind()
#include <string>
// Here are all the techniques discussed in the header.
@@ -142,7 +141,7 @@ void test_cost_of_obstruction(std::string const& s)
std::cout
<< " Class " << s << " has size " << sizeof(T) << '\n'
<< " Speed test: \n "
- << TimeAnAliquot(boost::bind(mete<T>, 0))
+ << TimeAnAliquot(std::bind(mete<T>, 0))
<< '\n'
;
}
diff --git a/timer.hpp b/timer.hpp
index 4c13785..76d98fa 100644
--- a/timer.hpp
+++ b/timer.hpp
@@ -122,7 +122,7 @@ class LMI_SO Timer
///
/// Template parameter 'F' is the type of the first ctor parameter,
/// which either is a nullary function or behaves like one. A facility
-/// such as boost::bind() is useful for reducing the arity of the
+/// such as std::bind() is useful for reducing the arity of the
/// argument (see unit test). Naturally, this is subject to the
/// Forwarding Problem, but that's inherent in the language.
///
@@ -256,7 +256,7 @@ std::ostream& operator<<(std::ostream& os, AliquotTimer<F>
const& z)
/// template is more convenient to use than the class template in
/// terms of which it is implemented. This is particularly valuable
/// when that type cannot readily be named--or is indeed unspecified,
-/// as when boost::bind() is used.
+/// as when std::bind() is used.
///
/// The maximum time defaults to one second, which is generally long
/// enough to get a stable measurement.
diff --git a/timer_test.cpp b/timer_test.cpp
index d5d56d2..801e8c5 100644
--- a/timer_test.cpp
+++ b/timer_test.cpp
@@ -27,9 +27,8 @@
#include "miscellany.hpp"
#include "test_tools.hpp"
-#include <boost/bind.hpp>
-
#include <cmath>
+#include <functional> // std::bind()
inline void do_nothing()
{}
@@ -114,7 +113,7 @@ void TimerTest::TestAliquotTimer()
std::cout << " " << TimeAnAliquot(foo, 0.1) << '\n';
X x;
- std::cout << " " << TimeAnAliquot(boost::bind(goo, 10, x, x, &x), 0.1) <<
'\n';
+ std::cout << " " << TimeAnAliquot(std::bind(goo, 10, x, x, &x), 0.1) <<
'\n';
std::string takes_too_long = TimeAnAliquot(WaitTenMsec, 0.0099999).str();
BOOST_TEST(contains(takes_too_long, "took longer"));
diff --git a/vector_test.cpp b/vector_test.cpp
index c879df6..cc0ddcd 100644
--- a/vector_test.cpp
+++ b/vector_test.cpp
@@ -270,7 +270,7 @@ void demo1()
namespace
{
// Global variables for timing tests. It would be in better taste
- // to pass them as arguments, using boost::bind. However, that
+ // to pass them as arguments, using std::bind. However, that
// would rule out using some compilers (e.g., borland), and it's
// best to test this with as many different toolsets as possible.