lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 89e939b 16/16: Prefer lmi::ssize() to member


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 89e939b 16/16: Prefer lmi::ssize() to member size()
Date: Thu, 15 Nov 2018 17:37:05 -0500 (EST)

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

    Prefer lmi::ssize() to member size()
---
 commutation_functions.cpp | 11 ++++++-----
 gpt_test.cpp              | 12 ++++++------
 ihs_irc7702.cpp           |  4 ++--
 input_sequence_aux.hpp    |  5 +++--
 ledger_text_formats.cpp   |  3 ++-
 mortality_rates_test.cpp  |  2 +-
 6 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/commutation_functions.cpp b/commutation_functions.cpp
index 9d7da3d..aaea771 100644
--- a/commutation_functions.cpp
+++ b/commutation_functions.cpp
@@ -25,6 +25,7 @@
 
 #include "assert_lmi.hpp"
 #include "et_vector.hpp"                // [VECTORIZE]
+#include "ssize_lmi.hpp"
 
 #include <algorithm>                    // rotate_copy() [VECTORIZE]
 #include <cmath>                        // pow()
@@ -49,8 +50,8 @@ OLCommFns::OLCommFns
     :q {a_q}
     ,i {a_i}
 {
-    Length = q.size();
-    LMI_ASSERT(i.size() == q.size());
+    Length = lmi::ssize(q);
+    LMI_ASSERT(lmi::ssize(i) == lmi::ssize(q));
 
 #if defined VECTORIZE
     ed.resize(Length);
@@ -126,9 +127,9 @@ ULCommFns::ULCommFns
     ,dbo_  {dbo}
     ,mode_ {mode}
 {
-    Length = qc.size();
-    LMI_ASSERT(ic.size() == qc.size());
-    LMI_ASSERT(ig.size() == qc.size());
+    Length = lmi::ssize(qc);
+    LMI_ASSERT(lmi::ssize(ic) == lmi::ssize(qc));
+    LMI_ASSERT(lmi::ssize(ig) == lmi::ssize(qc));
 
     ad.resize(1 + Length);
     kd.resize(    Length);
diff --git a/gpt_test.cpp b/gpt_test.cpp
index fbcfd1f..df110f4 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -40,7 +40,7 @@ namespace
 
 std::vector<double> a_to_m(std::vector<double> const& q_a)
 {
-    std::vector<double> q_m(q_a.size());
+    std::vector<double> q_m(lmi::ssize(q_a));
     assign(q_m, apply_binary(coi_rate_from_q<double>(), q_a, 1.0 / 11.0));
     return q_m;
 }
@@ -246,7 +246,7 @@ void gpt_test::initialize(int issue_age)
     static double const i_m_4 = i_upper_12_over_12_from_i<double>()(0.04);
     static double const i_m_6 = i_upper_12_over_12_from_i<double>()(0.06);
     q_m = sample_q(issue_age);
-    int const length = q_m.size();
+    int const length = lmi::ssize(q_m);
     glp_ic               .assign(length,     i_m_4);
     glp_ig               .assign(length,     i_m_4);
     gsp_ic               .assign(length,     i_m_6);
@@ -347,7 +347,7 @@ void gpt_test::test_invariants()
     parms = s_parms(); // Reset.
 
     // Duration greater than omega minus one.
-    parms.duration = q_m.size();
+    parms.duration = lmi::ssize(q_m);
     BOOST_TEST_THROW
         (z.calculate_premium(oe_gsp, mce_option1_for_7702, parms)
         ,std::runtime_error
@@ -420,7 +420,7 @@ Irc7702& gpt_test::instantiate_old(int issue_age)
 #if defined LMI_COMO_WITH_MINGW
     throw "Code that uses this obsolescent class segfaults with como.";
 #else // !defined LMI_COMO_WITH_MINGW
-    int const length = q_m.size();
+    int const length = lmi::ssize(q_m);
     std::vector<double> const zero(length, 0.0);
     // The old class recognizes only one QAB: ADB. So that all QABs
     // can be exercised with the new class, use a linear combination
@@ -501,7 +501,7 @@ void gpt_test::compare_premiums(int issue_age, double 
target)
     z_old.Initialize7702(f3bft, endt_bft, mce_option1_for_7702, target);
 #endif // !defined LMI_COMO_WITH_MINGW
 
-    int const omega = sample_q(0).size();
+    int const omega = lmi::ssize(sample_q(0));
     LMI_ASSERT(lmi::ssize(qab_waiver_rate) == omega - issue_age);
     for(int duration = 0; duration < omega - issue_age; ++duration)
         {
@@ -546,7 +546,7 @@ void gpt_test::compare_premiums(int issue_age, double 
target)
 
 void gpt_test::test_premium_calculations()
 {
-    int const omega = sample_q(0).size();
+    int const omega = lmi::ssize(sample_q(0));
 
     for(int issue_age = 0; issue_age < omega; ++issue_age)
         {
diff --git a/ihs_irc7702.cpp b/ihs_irc7702.cpp
index 31ec186..4b42697 100644
--- a/ihs_irc7702.cpp
+++ b/ihs_irc7702.cpp
@@ -385,7 +385,7 @@ double Irc7702::Forceout()
 //============================================================================
 void Irc7702::Init()
 {
-    Length = Qc.size();
+    Length = lmi::ssize(Qc);
     // TODO ?? Assumes that endowment age is always 100--should pass as arg 
instead.
     // TAXATION !! Is the comment above correct? Maturity age is passed as an 
argument.
     LMI_ASSERT(Length == EndtAge - IssueAge);
@@ -950,7 +950,7 @@ void Irc7702::InitSevenPayPrem()
         // 7PP = MO / (N0-N7) (limit 7 to maturity year)
         // TAXATION !! add flat extras to 7PP?
         double denom = CFFourPctMin->N()[j];
-        if((7 + j) < q.size())
+        if((7 + j) < lmi::ssize(q))
             {
             denom -= CFFourPctMin->N()[7 + j];
             }
diff --git a/input_sequence_aux.hpp b/input_sequence_aux.hpp
index 97d5674..01508de 100644
--- a/input_sequence_aux.hpp
+++ b/input_sequence_aux.hpp
@@ -33,6 +33,7 @@
 #include "input_sequence.hpp"
 #include "mc_enum.hpp"
 #include "so_attributes.hpp"
+#include "ssize_lmi.hpp"
 #include "tn_range.hpp"
 
 #include <map>
@@ -54,7 +55,7 @@ namespace detail
         ,std::vector<double> const& src
         )
     {
-        int len = src.size();
+        int len = lmi::ssize(src);
         dst.resize(len);
         for(int j = 0; j < len; ++j)
             {
@@ -70,7 +71,7 @@ namespace detail
         ,std::string              const& default_keyword
         )
     {
-        int len = src.size();
+        int len = lmi::ssize(src);
         dst.resize(len);
         for(int j = 0; j < len; ++j)
             {
diff --git a/ledger_text_formats.cpp b/ledger_text_formats.cpp
index c8da833..5289bae 100644
--- a/ledger_text_formats.cpp
+++ b/ledger_text_formats.cpp
@@ -38,6 +38,7 @@
 #include "map_lookup.hpp"
 #include "mc_enum_types_aux.hpp"        // is_subject_to_ill_reg()
 #include "miscellany.hpp"
+#include "ssize_lmi.hpp"
 #include "value_cast.hpp"
 
 #include <algorithm>                    // find()
@@ -876,7 +877,7 @@ namespace
     int const g_width = 128;
     std::string center(std::string const& s)
         {
-        int const z = s.length();
+        int const z = lmi::ssize(s);
         // Strings in the input class might be too wide; absent more
         // graceful handling, at least no attempt is made to cure that
         // problem with a negative number of spaces.
diff --git a/mortality_rates_test.cpp b/mortality_rates_test.cpp
index 9b4bb91..f2683f9 100644
--- a/mortality_rates_test.cpp
+++ b/mortality_rates_test.cpp
@@ -168,7 +168,7 @@ void mortality_rates_test::test_guaranteed_rates
     )
 {
     MortalityRates z;
-    z.Length_            = annual_rates().size();
+    z.Length_            = lmi::ssize(annual_rates());
 
     z.GCoiMultiplier_    = std::vector<double>(z.Length_, mult);
     z.MaxMonthlyCoiRate_ = max;



reply via email to

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