lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master aa7ac8c 1/2: Mostly get rid of std::binary_fu


From: Greg Chicares
Subject: [lmi-commits] [lmi] master aa7ac8c 1/2: Mostly get rid of std::binary_function and std::unary_function
Date: Thu, 14 Mar 2019 19:25:17 -0400 (EDT)

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

    Mostly get rid of std::binary_function and std::unary_function
    
    These were deprecated in C++11 and removed in C++17; and they were
    never used except by std::not{1,2} and std::bind{1st,2nd} anyway in
    the standard library...and by lmi extensions to PETE.
---
 expression_template_0_test.cpp |  1 -
 gpt_server.hpp                 |  3 ---
 illustrator.hpp                |  2 --
 math_functions.hpp             | 11 ++++-------
 math_functions_test.cpp        |  5 -----
 mec_server.hpp                 |  3 ---
 round_to.hpp                   |  2 --
 stratified_algorithms.hpp      | 10 ----------
 vector_test.cpp                |  1 -
 9 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/expression_template_0_test.cpp b/expression_template_0_test.cpp
index 0fe53aa..0f1bacd 100644
--- a/expression_template_0_test.cpp
+++ b/expression_template_0_test.cpp
@@ -71,7 +71,6 @@ namespace
 {
 template<typename T>
 struct greater_of
-    :public std::binary_function<T,T,T>
 {
     T operator()(T const& x, T const& y) const
         {
diff --git a/gpt_server.hpp b/gpt_server.hpp
index 8ec78a0..06cc928 100644
--- a/gpt_server.hpp
+++ b/gpt_server.hpp
@@ -30,8 +30,6 @@
 
 #include <boost/filesystem/path.hpp>
 
-#include <functional>
-
 class gpt_input;
 
 /// Guideline premium test server.
@@ -47,7 +45,6 @@ class gpt_input;
 /// Implicitly-declared special member functions do the right thing.
 
 class LMI_SO gpt_server final
-    :public std::unary_function<fs::path const&, bool>
 {
   public:
     explicit gpt_server(mcenum_emission);
diff --git a/illustrator.hpp b/illustrator.hpp
index d2a01bf..fa64d6e 100644
--- a/illustrator.hpp
+++ b/illustrator.hpp
@@ -29,7 +29,6 @@
 
 #include <boost/filesystem/path.hpp>
 
-#include <functional>
 #include <memory>                       // shared_ptr
 #include <vector>
 
@@ -41,7 +40,6 @@ class Ledger;
 /// Implicitly-declared special member functions do the right thing.
 
 class LMI_SO illustrator final
-    :public std::unary_function<fs::path const&, bool>
 {
   public:
     explicit illustrator(mcenum_emission);
diff --git a/math_functions.hpp b/math_functions.hpp
index cfb599f..7d3ed93 100644
--- a/math_functions.hpp
+++ b/math_functions.hpp
@@ -29,7 +29,7 @@
 
 #include <algorithm>                    // max(), min()
 #include <cmath>                        // expm1(), log1p()
-#include <functional>
+#include <functional>                   // unary_function, binary_function
 #include <limits>
 #include <stdexcept>
 #include <type_traits>
@@ -38,8 +38,9 @@
 // TODO ?? Write functions here for other refactorable uses of
 // std::pow() throughout lmi, to facilitate reuse and unit testing.
 
-// Many of these are Adaptable Unary or Binary Functions because that
-// was good C++98 practice.
+// Some of these derive from std::unary_function or std::binary_function
+// because that's still required by std::binder1st() or std::binder2nd(),
+// or by PETE.
 
 template<typename T>
 struct greater_of
@@ -168,7 +169,6 @@ struct i_upper_12_over_12_from_i
 
 template<typename T, int n>
 struct i_from_i_upper_n_over_n
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     static_assert(0 < n);
@@ -183,7 +183,6 @@ struct i_from_i_upper_n_over_n
 
 template<typename T>
 struct i_from_i_upper_12_over_12
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& i) const
@@ -194,7 +193,6 @@ struct i_from_i_upper_12_over_12
 
 template<typename T, int n>
 struct d_upper_n_from_i
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     static_assert(0 < n);
@@ -220,7 +218,6 @@ struct d_upper_n_from_i
 
 template<typename T>
 struct d_upper_12_from_i
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& i) const
diff --git a/math_functions_test.cpp b/math_functions_test.cpp
index b17c59b..25cf2a9 100644
--- a/math_functions_test.cpp
+++ b/math_functions_test.cpp
@@ -31,7 +31,6 @@
 
 #include <algorithm>                    // min()
 #include <cmath>                        // isnan(), pow()
-#include <functional>
 #include <iomanip>
 #include <limits>
 #include <type_traits>
@@ -47,7 +46,6 @@ namespace
 
 template<typename T>
 struct i_upper_12_over_12_from_i_naive
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& i) const
@@ -59,7 +57,6 @@ struct i_upper_12_over_12_from_i_naive
 
 template<typename T>
 struct i_from_i_upper_12_over_12_naive
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& i) const
@@ -71,7 +68,6 @@ struct i_from_i_upper_12_over_12_naive
 
 template<typename T>
 struct d_upper_12_from_i_naive
-    :public std::unary_function<T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& i) const
@@ -102,7 +98,6 @@ struct net_i_from_gross_naive
 
 template<typename T>
 struct coi_rate_from_q_naive
-    :public std::binary_function<T,T,T>
 {
     static_assert(std::is_floating_point<T>::value);
     T operator()(T const& q, T const& max_coi) const
diff --git a/mec_server.hpp b/mec_server.hpp
index 3d1f198..6ccff4b 100644
--- a/mec_server.hpp
+++ b/mec_server.hpp
@@ -30,8 +30,6 @@
 
 #include <boost/filesystem/path.hpp>
 
-#include <functional>
-
 class mec_input;
 
 /// MEC-testing server.
@@ -47,7 +45,6 @@ class mec_input;
 /// Implicitly-declared special member functions do the right thing.
 
 class LMI_SO mec_server final
-    :public std::unary_function<fs::path const&, bool>
 {
   public:
     explicit mec_server(mcenum_emission);
diff --git a/round_to.hpp b/round_to.hpp
index 6713cda..667d929 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -28,7 +28,6 @@
 #include "stl_extensions.hpp"           // nonstd::power()
 
 #include <cmath>
-#include <functional>
 #include <limits>
 #include <stdexcept>
 #include <type_traits>
@@ -251,7 +250,6 @@ RealType erroneous_rounding_function(RealType)
 
 template<typename RealType>
 class round_to
-    :public std::unary_function<RealType,RealType>
 {
     static_assert(std::is_floating_point<RealType>::value);
 
diff --git a/stratified_algorithms.hpp b/stratified_algorithms.hpp
index 2174076..8d103a4 100644
--- a/stratified_algorithms.hpp
+++ b/stratified_algorithms.hpp
@@ -28,7 +28,6 @@
 #include "miscellany.hpp"               // minmax
 
 #include <algorithm>                    // is_sorted(), upper_bound()
-#include <functional>
 #include <vector>
 
 /// Numerical algorithms for stratified rates.
@@ -90,11 +89,6 @@ namespace tiered_and_banded_rates{} // doxygen workaround.
 // TieredGrossToNet() and TieredNetToGross() seem to be two-bracket
 // specializations that should be replaced by something more generic.
 //
-// 'tiered_product' and 'tiered_rate' masquerade as binary functions,
-// but they are not. The arguments could be grouped in std::pair
-// instances if binary functions are really needed, but probably it
-// would be better not to derive from std::binary_function at all.
-//
 // 'tiered' and 'banded' limits are expressed differently: as
 // incremental and cumulative limits, respectively. This may confuse
 // the careless reader, but presents limits to the product-editor user
@@ -130,7 +124,6 @@ double TieredNetToGross
 
 template<typename T>
 struct tiered_product
-    :public std::binary_function<T, T, T>
 {
     T operator()
         (T const&              new_incremental_amount
@@ -217,7 +210,6 @@ T tiered_product<T>::operator()
 
 template<typename T>
 struct tiered_rate
-    :public std::binary_function<T, T, T>
 {
     T operator()
         (T const& amount
@@ -253,7 +245,6 @@ T tiered_rate<T>::operator()
 
 template<typename T>
 struct banded_rate
-    :public std::binary_function<T, T, T>
 {
     T operator()
         (T const&              total_amount
@@ -317,7 +308,6 @@ T banded_rate<T>::operator()
 
 template<typename T>
 struct banded_product
-    :public std::binary_function<T, T, T>
 {
     T operator()
         (T const&              total_amount
diff --git a/vector_test.cpp b/vector_test.cpp
index 1d6226e..d451315 100644
--- a/vector_test.cpp
+++ b/vector_test.cpp
@@ -59,7 +59,6 @@
 //
 //   template<typename T>
 //   struct plus
-//       :binary_function<T,T,T>
 //   {
 //       T operator()(T const& t0, T const& t1) const {return t0 + t1;}
 //   }



reply via email to

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