lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 14b1ede: Replace nonstd by std copy_n(), iota


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 14b1ede: Replace nonstd by std copy_n(), iota(), is_sorted()
Date: Thu, 22 Dec 2016 23:12:06 +0000 (UTC)

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

    Replace nonstd by std copy_n(), iota(), is_sorted()
    
    These three function templates, previously implemented in namespace
    nonstd, have been incorporated into the C++ standard--see:
      http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2569.pdf
    The author of that document is the author of the documentation
    accompanying the sgi stl, whence the removed nonstd implementations
    were copied, and the specifications in the C++11 standard appear to
    be equivalent.
---
 gpt_test.cpp                   |    4 +--
 ihs_acctval.cpp                |    5 +--
 input_realization.cpp          |    3 +-
 stl_extensions.hpp             |   76 ----------------------------------------
 stratified_algorithms.hpp      |    5 ++-
 stratified_algorithms_test.cpp |    2 +-
 6 files changed, 7 insertions(+), 88 deletions(-)

diff --git a/gpt_test.cpp b/gpt_test.cpp
index 392466e..f8b8d08 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -27,10 +27,10 @@
 #include "assert_lmi.hpp"
 #include "materially_equal.hpp"
 #include "math_functors.hpp"
-#include "stl_extensions.hpp"           // nonstd::iota()
 #include "test_tools.hpp"
 #include "timer.hpp"
 
+#include <numeric>                      // std::iota()
 #include <vector>
 
 namespace
@@ -263,7 +263,7 @@ void gpt_test::initialize(int issue_age)
     qab_waiver_rate      .assign(length,  0.000029);
 
     std::vector<int>    iota_i(length);
-    nonstd::iota(iota_i.begin(), iota_i.end(), issue_age);
+    std::iota(iota_i.begin(), iota_i.end(), issue_age);
     std::vector<double> iota_d(length, 0.0);
     iota_d += 1.0 + 0.001 * iota_i;
     glp_ic               *= iota_d;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 6efa4dc..f81f075 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -43,7 +43,6 @@
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
 #include "premium_tax.hpp"
-#include "stl_extensions.hpp"
 #include "stratified_algorithms.hpp"
 #include "surrchg_rates.hpp"
 
@@ -526,9 +525,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
         {
         int length_7702a = std::min(7, BasicValues::GetLength());
         // Premium history starts at contract year zero.
-        // TAXATION !! nonstd::copy_n() is used nowhere else, and
-        // may be expunged if this line becomes unnecessary.
-        nonstd::copy_n
+        std::copy_n
             (yare_input_.Inforce7702AAmountsPaidHistory.begin()
             ,length_7702a
             ,std::back_inserter(pmts_7702a)
diff --git a/input_realization.cpp b/input_realization.cpp
index a5a951e..b7c954d 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -33,7 +33,6 @@
 #include "input_seq_helpers.hpp"
 #include "miscellany.hpp"               // minmax
 #include "round_to.hpp"
-#include "stl_extensions.hpp"           // nonstd::is_sorted()
 #include "value_cast.hpp"
 
 #include <boost/bind.hpp>
@@ -547,7 +546,7 @@ std::string Input::RealizeDeathBenefitOption()
 
     if
         (   !database_->Query(DB_AllowChangeToDbo2)
-        &&  !nonstd::is_sorted
+        &&  !std::is_sorted
                 (DeathBenefitOptionRealized_.begin()
                 ,DeathBenefitOptionRealized_.end()
                 ,boost::bind
diff --git a/stl_extensions.hpp b/stl_extensions.hpp
index b02af4b..1ec7820 100644
--- a/stl_extensions.hpp
+++ b/stl_extensions.hpp
@@ -58,82 +58,6 @@
 
 namespace nonstd
 {
-template<typename InputIterator, typename Size, typename OutputIterator>
-void copy_n(InputIterator first, Size count, OutputIterator result)
-{
-    Size j = count;
-    for(; 0 < j; --j)
-        {
-        *result = *first;
-        ++first;
-        ++result;
-        }
-}
-
-/// is_sorted, a predicate testing whether a range is sorted in
-/// nondescending order.  This is an extension, not part of the C++
-/// standard.
-
-template<typename ForwardIterator>
-bool is_sorted
-    (ForwardIterator first
-    ,ForwardIterator last
-    )
-{
-    if(first == last)
-        {
-        return true;
-        }
-
-    ForwardIterator next = first;
-    for(++next; next != last; first = next, ++next)
-        {
-        if(*next < *first)
-            {
-            return false;
-            }
-        }
-
-    return true;
-}
-
-template<typename ForwardIterator, typename StrictWeakOrdering>
-bool is_sorted
-    (ForwardIterator first
-    ,ForwardIterator last
-    ,StrictWeakOrdering comp
-    )
-{
-    if(first == last)
-        {
-        return true;
-        }
-
-    ForwardIterator next = first;
-    for(++next; next != last; first = next, ++next)
-        {
-        if(comp(*next, *first))
-            {
-            return false;
-            }
-        }
-
-    return true;
-}
-
-template<typename ForwardIterator, typename T>
-void iota
-    (ForwardIterator first
-    ,ForwardIterator last
-    ,T               value
-    )
-{
-    while(first != last)
-        {
-        *first++ = value++;
-        }
-}
-
 /// Identity element.
 
 template <typename T> inline T identity_element(std::plus<T>)
diff --git a/stratified_algorithms.hpp b/stratified_algorithms.hpp
index 0c276b6..40c6321 100644
--- a/stratified_algorithms.hpp
+++ b/stratified_algorithms.hpp
@@ -26,9 +26,8 @@
 
 #include "assert_lmi.hpp"
 #include "miscellany.hpp"               // minmax
-#include "stl_extensions.hpp"           // nonstd::is_sorted()
 
-#include <algorithm>                    // std::upper_bound()
+#include <algorithm>                    // std::is_sorted(), std::upper_bound()
 #include <functional>
 #include <vector>
 
@@ -301,7 +300,7 @@ T banded_rate<T>::operator()
     LMI_ASSERT(zero <  extrema.maximum());
 
     std::vector<T> const& z(cumulative_limits);
-    LMI_ASSERT(nonstd::is_sorted(z.begin(), z.end()));
+    LMI_ASSERT(std::is_sorted(z.begin(), z.end()));
 
     // Ignore the last limit. It's asserted elsewhere to be infinity.
     std::vector<double>::const_iterator band = std::upper_bound
diff --git a/stratified_algorithms_test.cpp b/stratified_algorithms_test.cpp
index 307d033..5fb1b1a 100644
--- a/stratified_algorithms_test.cpp
+++ b/stratified_algorithms_test.cpp
@@ -123,7 +123,7 @@ void banded_test()
     BOOST_TEST_THROW
         (banded_rate<double>()(0.0, decreasing, rates)
         ,std::runtime_error
-        ,"Assertion 'nonstd::is_sorted(z.begin(), z.end())' failed."
+        ,"Assertion 'std::is_sorted(z.begin(), z.end())' failed."
         );
 }
 



reply via email to

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