lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 048b225: Avoid gratuitous use of unsigned int


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 048b225: Avoid gratuitous use of unsigned int
Date: Mon, 4 Jun 2018 18:08:38 -0400 (EDT)

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

    Avoid gratuitous use of unsigned int
---
 actuarial_table.cpp            |  3 +-
 commutation_functions_test.cpp | 13 +++----
 dbvalue.cpp                    |  4 +--
 financial_test.cpp             |  3 +-
 gpt_commutation_functions.cpp  | 33 ++++++++---------
 gpt_commutation_functions.hpp  |  4 +--
 gpt_server.cpp                 |  3 +-
 gpt_test.cpp                   |  3 +-
 ihs_acctval.cpp                |  5 +--
 ihs_irc7702.cpp                | 82 +++++++++++++++++++-----------------------
 ihs_irc7702a.cpp               |  6 ++--
 ihs_irc7702a.hpp               |  2 +-
 input_realization.cpp          |  4 +--
 input_sequence_entry.cpp       |  7 ++--
 interest_rates.cpp             | 31 ++++++++--------
 ledger_invariant.cpp           |  3 +-
 ledger_xml_io.cpp              |  7 ++--
 main_cgi.cpp                   |  3 +-
 mec_server.cpp                 |  3 +-
 mortality_rates_test.cpp       |  3 +-
 multiple_cell_document.cpp     | 13 +++----
 timer_test.cpp                 |  4 +--
 22 files changed, 120 insertions(+), 119 deletions(-)

diff --git a/actuarial_table.cpp b/actuarial_table.cpp
index c8babd1..ce11e3a 100644
--- a/actuarial_table.cpp
+++ b/actuarial_table.cpp
@@ -30,6 +30,7 @@
 #include "miscellany.hpp"
 #include "oecumenic_enumerations.hpp"   // methuselah
 #include "path_utility.hpp"             // fs::path inserter
+#include "ssize_lmi.hpp"
 
 #include <boost/filesystem/convenience.hpp>
 #include <boost/filesystem/fstream.hpp>
@@ -556,7 +557,7 @@ std::vector<double> actuarial_table::specific_values
                 ;
             }
         }
-    LMI_ASSERT(v.size() == static_cast<unsigned int>(length));
+    LMI_ASSERT(lmi::ssize(v) == length);
     return v;
 }
 
diff --git a/commutation_functions_test.cpp b/commutation_functions_test.cpp
index 9f639e5..f0424fd 100644
--- a/commutation_functions_test.cpp
+++ b/commutation_functions_test.cpp
@@ -26,6 +26,7 @@
 #include "et_vector.hpp"
 #include "math_functions.hpp"
 #include "miscellany.hpp"               // lmi_array_size()
+#include "ssize_lmi.hpp"
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -178,7 +179,7 @@ void TestEckleyTable2()
     {
     double tolerance = 0.0000005;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < coi.size(); ++j)
+    for(int j = 0; j < lmi::ssize(coi); ++j)
         {
         double d0 = std::fabs(nsp    [j] - Ax[j]);
         double d1 = std::fabs(annuity[j] - ax[j]);
@@ -213,7 +214,7 @@ void TestEckleyTable2()
     {
     double tolerance = 0.000005;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < coi.size(); ++j)
+    for(int j = 0; j < lmi::ssize(coi); ++j)
         {
         double d0 = std::fabs(premium[j] - Px[j] * .001);
         double d1 = std::fabs(reserve[j] - Vx[j] * .001);
@@ -300,7 +301,7 @@ void TestEckleyTables3and4()
 
     double tolerance = 0.000005;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < coi.size(); ++j)
+    for(int j = 0; j < lmi::ssize(coi); ++j)
         {
         double d0 = std::fabs(premium[j] - Px[j] * .001);
         double d1 = std::fabs(reserve[j] - Vx[j] * .001);
@@ -383,7 +384,7 @@ void TestEckleyTable5()
 
     double tolerance = 0.0000005;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < coi.size(); ++j)
+    for(int j = 0; j < lmi::ssize(coi); ++j)
         {
         double d0 = std::fabs(CF.aD()[j]        - Dx  [j]);
         double d1 = std::fabs(CF.kD()[j] / 12.0 - Dx12[j]);
@@ -533,7 +534,7 @@ void Test_1954_1958_IET_3pct()
 
     double tolerance = 0.01;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < q.size(); ++j)
+    for(int j = 0; j < lmi::ssize(q); ++j)
         {
         double d0 = std::fabs(Dx[0] * CF.D()[j] - Dx[j]);
         double d1 = std::fabs(Dx[0] * CF.N()[j] - Nx[j]);
@@ -653,7 +654,7 @@ void Test_1980_CSO_Male_ANB()
 
     double tolerance = 1.0e-13;
     double worst_discrepancy = 0.0;
-    for(unsigned int j = 0; j < q.size(); ++j)
+    for(int j = 0; j < lmi::ssize(q); ++j)
         {
         double d0 = std::fabs(reserve[j] - Vx[j]);
         worst_discrepancy = std::max(worst_discrepancy, d0);
diff --git a/dbvalue.cpp b/dbvalue.cpp
index 8508950..d932519 100644
--- a/dbvalue.cpp
+++ b/dbvalue.cpp
@@ -252,7 +252,7 @@ double& database_entity::operator[](std::vector<int> const& 
index)
     LMI_ASSERT(e_number_of_axes == index.size());
 
     int z = 0;
-    for(unsigned int j = 0; j < e_number_of_axes; ++j)
+    for(int j = 0; j < e_number_of_axes; ++j)
         {
         if(1 != axis_lengths_[j])
             {
@@ -281,7 +281,7 @@ double const* database_entity::operator[](database_index 
const& idx) const
     LMI_ASSERT(e_number_of_axes == 1 + index.size());
 
     int z = 0;
-    for(unsigned int j = 0; j < e_number_of_axes - 1; ++j)
+    for(int j = 0; j < e_number_of_axes - 1; ++j)
         {
         if(1 != axis_lengths_[j])
             {
diff --git a/financial_test.cpp b/financial_test.cpp
index dd60c5e..797db68 100644
--- a/financial_test.cpp
+++ b/financial_test.cpp
@@ -24,6 +24,7 @@
 #include "financial.hpp"
 
 #include "materially_equal.hpp"
+#include "ssize_lmi.hpp"
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -191,7 +192,7 @@ int test_main(int, char*[])
     static double const one_plus_i = 1.0 + i;
     std::vector<double> accum_p(p.size());
     accum_p[0] = p[0] * one_plus_i;
-    for(unsigned int j = 1; j < p.size(); ++j)
+    for(int j = 1; j < lmi::ssize(p); ++j)
         {
         accum_p[j] = (accum_p[j - 1] + p[j]) * one_plus_i;
         }
diff --git a/gpt_commutation_functions.cpp b/gpt_commutation_functions.cpp
index 875bfa3..1290e0d 100644
--- a/gpt_commutation_functions.cpp
+++ b/gpt_commutation_functions.cpp
@@ -27,6 +27,7 @@
 #include "commutation_functions.hpp"
 #include "et_vector.hpp"
 #include "miscellany.hpp"               // minmax
+#include "ssize_lmi.hpp"
 
 #include <algorithm>                    // min_element()
 #include <numeric>                      // partial_sum()
@@ -102,20 +103,20 @@ gpt_commfns::gpt_commfns
     ,N_qab_waiver_ (length_)
 {
     LMI_ASSERT(0 < length_ && length_ < methuselah);
-    LMI_ASSERT(length_ == qc                          .size());
-    LMI_ASSERT(length_ == ic                          .size());
-    LMI_ASSERT(length_ == ig                          .size());
-    LMI_ASSERT(length_ == charges.prem_load_target    .size());
-    LMI_ASSERT(length_ == charges.prem_load_excess    .size());
-    LMI_ASSERT(length_ == charges.policy_fee_monthly  .size());
-    LMI_ASSERT(length_ == charges.policy_fee_annual   .size());
-    LMI_ASSERT(length_ == charges.specamt_load_monthly.size());
-    LMI_ASSERT(length_ == charges.qab_gio_rate        .size());
-    LMI_ASSERT(length_ == charges.qab_adb_rate        .size());
-    LMI_ASSERT(length_ == charges.qab_term_rate       .size());
-    LMI_ASSERT(length_ == charges.qab_spouse_rate     .size());
-    LMI_ASSERT(length_ == charges.qab_child_rate      .size());
-    LMI_ASSERT(length_ == charges.qab_waiver_rate     .size());
+    LMI_ASSERT(length_ == lmi::ssize(qc                          ));
+    LMI_ASSERT(length_ == lmi::ssize(ic                          ));
+    LMI_ASSERT(length_ == lmi::ssize(ig                          ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.prem_load_target    ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.prem_load_excess    ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.policy_fee_monthly  ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.policy_fee_annual   ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.specamt_load_monthly));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_gio_rate        ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_adb_rate        ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_term_rate       ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_spouse_rate     ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_child_rate      ));
+    LMI_ASSERT(length_ == lmi::ssize(charges.qab_waiver_rate     ));
 
     typedef minmax<double> mm;
     mm a(        qc                  ); LMI_ASSERT(0.0 <= a && a <= 1.0);
@@ -240,8 +241,8 @@ double gpt_cf_triad::calculate_premium
     ,gpt_scalar_parms const& args
     ) const
 {
-    LMI_ASSERT(0 <= args.duration);
-    LMI_ASSERT(static_cast<unsigned int>(args.duration) < length_);
+    LMI_ASSERT(0 <= args.duration        );
+    LMI_ASSERT(args.duration < length_   );
     LMI_ASSERT(0.0 <= args.target        );
     LMI_ASSERT(0.0 <= args.f3bft         );
     LMI_ASSERT(0.0 <= args.endt_bft      );
diff --git a/gpt_commutation_functions.hpp b/gpt_commutation_functions.hpp
index 6912ded..92fbe9e 100644
--- a/gpt_commutation_functions.hpp
+++ b/gpt_commutation_functions.hpp
@@ -151,7 +151,7 @@ class gpt_commfns
 
     double calculate_premium(oenum_glp_or_gsp, gpt_scalar_parms const&) const;
 
-    unsigned int const  length_;
+    int const           length_;
     std::vector<double> M_;
     double              D_endt_;
     std::vector<double> D_net_tgt_;
@@ -199,7 +199,7 @@ class gpt_cf_triad
         ) const;
 
   private:
-    unsigned int const length_;
+    int const   length_;
     gpt_commfns cf_glp_dbo_1;
     gpt_commfns cf_glp_dbo_2;
     gpt_commfns cf_gsp;
diff --git a/gpt_server.cpp b/gpt_server.cpp
index a445b7d..92a8fcf 100644
--- a/gpt_server.cpp
+++ b/gpt_server.cpp
@@ -46,6 +46,7 @@
 #include "premium_tax.hpp"
 #include "product_data.hpp"
 #include "round_to.hpp"
+#include "ssize_lmi.hpp"
 #include "stratified_algorithms.hpp"    // TieredGrossToNet()
 #include "stratified_charges.hpp"
 #include "timer.hpp"
@@ -337,7 +338,7 @@ gpt_state test_one_days_gpt_transactions
     double const LoadTarget = target_sales_load[InforceYear] + 
target_premium_load[InforceYear] + dac_tax_load[InforceYear] + premium_tax_load;
     double const LoadExcess = excess_sales_load[InforceYear] + 
excess_premium_load[InforceYear] + dac_tax_load[InforceYear] + premium_tax_load;
 
-    LMI_ASSERT(static_cast<unsigned int>(InforceContractYear) < 
input.BenefitHistoryRealized().size());
+    LMI_ASSERT(InforceContractYear < 
lmi::ssize(input.BenefitHistoryRealized()));
     double const old_benefit_amount = 
input.BenefitHistoryRealized()[InforceContractYear];
 
     double const total_1035_amount = round_max_premium
diff --git a/gpt_test.cpp b/gpt_test.cpp
index 9c5c0b8..fbcfd1f 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -27,6 +27,7 @@
 #include "assert_lmi.hpp"
 #include "materially_equal.hpp"
 #include "math_functions.hpp"
+#include "ssize_lmi.hpp"
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -501,7 +502,7 @@ void gpt_test::compare_premiums(int issue_age, double 
target)
 #endif // !defined LMI_COMO_WITH_MINGW
 
     int const omega = sample_q(0).size();
-    LMI_ASSERT(qab_waiver_rate.size() == static_cast<unsigned int>(omega - 
issue_age));
+    LMI_ASSERT(lmi::ssize(qab_waiver_rate) == omega - issue_age);
     for(int duration = 0; duration < omega - issue_age; ++duration)
         {
         parms.duration = duration;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 414a6c3..dde6bdc 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -43,6 +43,7 @@
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
 #include "premium_tax.hpp"
+#include "ssize_lmi.hpp"
 #include "stratified_algorithms.hpp"
 #include "surrchg_rates.hpp"
 
@@ -136,8 +137,8 @@ AccountValue::AccountValue(Input const& input)
     // Of course, a contract is not normally in force after maturity.
 
     LMI_ASSERT
-        (   InvariantValues().InforceLives.size()
-        ==  static_cast<unsigned int>(1 + BasicValues::GetLength())
+        (   lmi::ssize(InvariantValues().InforceLives)
+        ==  1 + BasicValues::GetLength()
         );
     partial_mortality_q.resize(BasicValues::GetLength());
     // TODO ?? 'InvariantValues().InforceLives' may be thought of as
diff --git a/ihs_irc7702.cpp b/ihs_irc7702.cpp
index e8ff861..cfe22c7 100644
--- a/ihs_irc7702.cpp
+++ b/ihs_irc7702.cpp
@@ -27,6 +27,7 @@
 #include "assert_lmi.hpp"
 #include "commutation_functions.hpp"
 #include "materially_equal.hpp"
+#include "ssize_lmi.hpp"
 #include "value_cast.hpp"
 
 #include <algorithm>
@@ -495,10 +496,7 @@ void Irc7702::InitCorridor()
         );
 
     // GPT corridor
-    LMI_ASSERT
-        (   static_cast<unsigned int>(IssueAge)
-        <=  CompleteGptCorridor().size()
-        );
+    LMI_ASSERT(IssueAge <= lmi::ssize(CompleteGptCorridor()));
     GptCorridor.assign
         (CompleteGptCorridor().begin() + IssueAge
         ,CompleteGptCorridor().end()
@@ -516,19 +514,11 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // Present value of charges per policy
 
-    // We want to make some assertions as to the lengths of certain
-    // vectors, and we don't want to see "comparing signed to unsigned"
-    // warnings. We prefer to avoid unsigned variables in general
-    // (see e.g. Lakos on this subject), so we use a local unsigned
-    // copy of Length.
-
-    unsigned int u_length = static_cast<unsigned int>(Length);
-
     // ET !! std::vector<double> ann_chg_pol = AnnChgPol * comm_fns.aD();
     std::vector<double> ann_chg_pol(Length);
-    LMI_ASSERT(u_length == ann_chg_pol.size());
-    LMI_ASSERT(u_length == AnnChgPol.size());
-    LMI_ASSERT(u_length == comm_fns.aD().size());
+    LMI_ASSERT(Length == lmi::ssize(ann_chg_pol));
+    LMI_ASSERT(Length == lmi::ssize(AnnChgPol));
+    LMI_ASSERT(Length == lmi::ssize(comm_fns.aD()));
     std::transform
         (AnnChgPol.begin()
         ,AnnChgPol.end()
@@ -539,9 +529,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // ET !! std::vector<double> mly_chg_pol = MlyChgPol * drop(comm_fns.kD(), 
-1);
     std::vector<double> mly_chg_pol(Length);
-    LMI_ASSERT(u_length == mly_chg_pol.size());
-    LMI_ASSERT(u_length == MlyChgPol.size());
-    LMI_ASSERT(u_length <= comm_fns.kD().size());
+    LMI_ASSERT(Length == lmi::ssize(mly_chg_pol));
+    LMI_ASSERT(Length == lmi::ssize(MlyChgPol));
+    LMI_ASSERT(Length <= lmi::ssize(comm_fns.kD()));
     std::transform
         (MlyChgPol.begin()
         ,MlyChgPol.end()
@@ -561,9 +551,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
     // ET !! PvChgPol[a_EIOBasis] = ann_chg_pol + mly_chg_pol;
     std::vector<double>& chg_pol = PvChgPol[a_EIOBasis];
     chg_pol.resize(Length);
-    LMI_ASSERT(u_length == chg_pol.size());
-    LMI_ASSERT(u_length == ann_chg_pol.size());
-    LMI_ASSERT(u_length <= mly_chg_pol.size());
+    LMI_ASSERT(Length == lmi::ssize(chg_pol));
+    LMI_ASSERT(Length == lmi::ssize(ann_chg_pol));
+    LMI_ASSERT(Length <= lmi::ssize(mly_chg_pol));
     std::transform
         (ann_chg_pol.begin()
         ,ann_chg_pol.end()
@@ -586,9 +576,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
     // ET !! PvChgSpecAmt[a_EIOBasis] = MlyChgSpecAmt * comm_fns.kD();
     std::vector<double>& chg_sa = PvChgSpecAmt[a_EIOBasis];
     chg_sa.resize(Length);
-    LMI_ASSERT(u_length == chg_sa.size());
-    LMI_ASSERT(u_length == MlyChgSpecAmt.size());
-    LMI_ASSERT(u_length == comm_fns.kD().size());
+    LMI_ASSERT(Length == lmi::ssize(chg_sa));
+    LMI_ASSERT(Length == lmi::ssize(MlyChgSpecAmt));
+    LMI_ASSERT(Length == lmi::ssize(comm_fns.kD()));
     std::transform
         (MlyChgSpecAmt.begin()
         ,MlyChgSpecAmt.end()
@@ -604,9 +594,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
     // ET !! PvChgADD[a_EIOBasis] = MlyChgADD * comm_fns.kD();
     std::vector<double>& chg_add = PvChgADD[a_EIOBasis];
     chg_add.resize(Length);
-    LMI_ASSERT(u_length == chg_add.size());
-    LMI_ASSERT(u_length == MlyChgADD.size());
-    LMI_ASSERT(u_length == comm_fns.kD().size());
+    LMI_ASSERT(Length == lmi::ssize(chg_add));
+    LMI_ASSERT(Length == lmi::ssize(MlyChgADD));
+    LMI_ASSERT(Length == lmi::ssize(comm_fns.kD()));
     std::transform
         (MlyChgADD.begin()
         ,MlyChgADD.end()
@@ -620,7 +610,7 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // APL: chg_mort gets rotate plus scan rotate kC
     std::vector<double>& chg_mort = PvChgMort[a_EIOBasis];
-    LMI_ASSERT(u_length <= comm_fns.kC().size());
+    LMI_ASSERT(Length <= lmi::ssize(comm_fns.kC()));
     chg_mort = comm_fns.kC();
     chg_mort.resize(Length);
     std::reverse(chg_mort.begin(), chg_mort.end());
@@ -631,14 +621,14 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // ET !! PvNpfSglTgt[a_EIOBasis] = (1.0 - LoadTgt) * comm_fns.aD();
     std::vector<double>& npf_sgl_tgt = PvNpfSglTgt[a_EIOBasis];
-//  LMI_ASSERT(u_length == npf_sgl_tgt.size()); // TAXATION !! Expunge if 
truly unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(npf_sgl_tgt)); // TAXATION !! Expunge if 
truly unwanted.
     npf_sgl_tgt = LoadTgt;
-    LMI_ASSERT(u_length == npf_sgl_tgt.size());
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_tgt));
     std::transform(npf_sgl_tgt.begin(), npf_sgl_tgt.end(), npf_sgl_tgt.begin()
         ,std::bind1st(std::minus<double>(), 1.0)
         );
-    LMI_ASSERT(u_length == npf_sgl_tgt.size());
-    LMI_ASSERT(u_length == comm_fns.aD().size());
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_tgt));
+    LMI_ASSERT(Length == lmi::ssize(comm_fns.aD()));
     std::transform
         (npf_sgl_tgt.begin()
         ,npf_sgl_tgt.end()
@@ -647,9 +637,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
         ,std::multiplies<double>()
         );
     std::vector<double>& npf_lvl_tgt = PvNpfLvlTgt[a_EIOBasis];
-//  LMI_ASSERT(u_length == npf_lvl_tgt.size()); // TAXATION !! Expunge if 
truly unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(npf_lvl_tgt)); // TAXATION !! Expunge if 
truly unwanted.
     npf_lvl_tgt = npf_sgl_tgt;
-    LMI_ASSERT(u_length == npf_lvl_tgt.size());
+    LMI_ASSERT(Length == lmi::ssize(npf_lvl_tgt));
     std::reverse(npf_lvl_tgt.begin(), npf_lvl_tgt.end());
     std::partial_sum(npf_lvl_tgt.begin(), npf_lvl_tgt.end(), 
npf_lvl_tgt.begin());
     std::reverse(npf_lvl_tgt.begin(), npf_lvl_tgt.end());
@@ -658,14 +648,14 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // ET !! PvNpfSglExc[a_EIOBasis] = (1.0 - LoadExc) * comm_fns.aD();
     std::vector<double>& npf_sgl_exc = PvNpfSglExc[a_EIOBasis];
-//  LMI_ASSERT(u_length == npf_sgl_exc.size()); // TAXATION !! Expunge if 
truly unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(npf_sgl_exc)); // TAXATION !! Expunge if 
truly unwanted.
     npf_sgl_exc = LoadExc;
-    LMI_ASSERT(u_length == npf_sgl_exc.size());
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_exc));
     std::transform(npf_sgl_exc.begin(), npf_sgl_exc.end(), npf_sgl_exc.begin()
         ,std::bind1st(std::minus<double>(), 1.0)
         );
-    LMI_ASSERT(u_length == npf_sgl_tgt.size()); // TAXATION !! Shouldn't this 
be npf_sgl_exc?
-    LMI_ASSERT(u_length == comm_fns.aD().size());
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_tgt)); // TAXATION !! Shouldn't 
this be npf_sgl_exc?
+    LMI_ASSERT(Length == lmi::ssize(comm_fns.aD()));
     std::transform
         (npf_sgl_exc.begin()
         ,npf_sgl_exc.end()
@@ -674,9 +664,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
         ,std::multiplies<double>()
         );
     std::vector<double>& npf_lvl_exc = PvNpfLvlExc[a_EIOBasis];
-//  LMI_ASSERT(u_length == npf_lvl_exc.size()); // TAXATION !! Expunge if 
truly unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(npf_lvl_exc)); // TAXATION !! Expunge if 
truly unwanted.
     npf_lvl_exc = npf_sgl_exc;
-    LMI_ASSERT(u_length == npf_lvl_exc.size());
+    LMI_ASSERT(Length == lmi::ssize(npf_lvl_exc));
     std::reverse(npf_lvl_exc.begin(), npf_lvl_exc.end());
     std::partial_sum(npf_lvl_exc.begin(), npf_lvl_exc.end(), 
npf_lvl_exc.begin());
     std::reverse(npf_lvl_exc.begin(), npf_lvl_exc.end());
@@ -685,11 +675,11 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
 
     // ET !! PvLoadDiffSgl[a_EIOBasis] = npf_sgl_exc - npf_sgl_tgt;
     std::vector<double>& diff_sgl = PvLoadDiffSgl[a_EIOBasis];
-//  LMI_ASSERT(u_length == diff_sgl.size()); // TAXATION !! Expunge if truly 
unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(diff_sgl)); // TAXATION !! Expunge if 
truly unwanted.
     diff_sgl.resize(Length);
-    LMI_ASSERT(u_length == diff_sgl.size());
-    LMI_ASSERT(u_length == npf_sgl_exc.size());
-    LMI_ASSERT(u_length == npf_sgl_tgt.size());
+    LMI_ASSERT(Length == lmi::ssize(diff_sgl));
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_exc));
+    LMI_ASSERT(Length == lmi::ssize(npf_sgl_tgt));
     std::transform
         (npf_sgl_exc.begin()
         ,npf_sgl_exc.end()
@@ -698,9 +688,9 @@ void Irc7702::InitPvVectors(EIOBasis const& a_EIOBasis)
         ,std::minus<double>()
         );
     std::vector<double>& diff_lvl = PvLoadDiffLvl[a_EIOBasis];
-//  LMI_ASSERT(u_length == diff_lvl.size()); // TAXATION !! Expunge if truly 
unwanted.
+//  LMI_ASSERT(Length == lmi::ssize(diff_lvl)); // TAXATION !! Expunge if 
truly unwanted.
     diff_lvl.resize(Length);
-    LMI_ASSERT(u_length == diff_lvl.size());
+    LMI_ASSERT(Length == lmi::ssize(diff_lvl));
     std::reverse(diff_lvl.begin(), diff_lvl.end());
     std::partial_sum(diff_lvl.begin(), diff_lvl.end(), diff_lvl.begin());
     std::reverse(diff_lvl.begin(), diff_lvl.end());
diff --git a/ihs_irc7702a.cpp b/ihs_irc7702a.cpp
index 884914e..5d00424 100644
--- a/ihs_irc7702a.cpp
+++ b/ihs_irc7702a.cpp
@@ -243,7 +243,7 @@ void Irc7702A::Initialize7702A
     Bfts.assign(max_dur, 0.0);
 
     LMI_ASSERT(lmi::ssize(a_Pmts) <= max_years);
-    for(unsigned int j = 0; j < a_Pmts.size(); ++j)
+    for(int j = 0; j < lmi::ssize(a_Pmts); ++j)
         {
         // TODO ?? TAXATION !! OK to treat premium history as annual?
         Pmts[j * months_per_year] = a_Pmts[j];
@@ -271,8 +271,8 @@ void Irc7702A::Initialize7702A
         ( (    PolicyYear +     PolicyMonth / 12.0)
         - (a_ContractYear + a_ContractMonth / 12.0)
         );
-    unsigned int const duration_of_last_mc = static_cast<unsigned int>(z);
-    LMI_ASSERT(duration_of_last_mc < SevenPPRateVec.size());
+    int const duration_of_last_mc = static_cast<int>(z);
+    LMI_ASSERT(duration_of_last_mc < lmi::ssize(SevenPPRateVec));
     Saved7PPRate    = SevenPPRateVec[duration_of_last_mc];
     state_.B2_deduced_px7_rate = SevenPPRateVec[duration_of_last_mc];
     SavedNecPrem    = 0.0;
diff --git a/ihs_irc7702a.hpp b/ihs_irc7702a.hpp
index 9614f20..fa853e2 100644
--- a/ihs_irc7702a.hpp
+++ b/ihs_irc7702a.hpp
@@ -56,7 +56,7 @@ class Irc7702A final
         ,std::vector<double> const&  a_NSPVec        // TODO ?? TAXATION !! 
Assume table passed, for now.
         ,round_to<double>    const&  a_RoundNonMecPrem
 // TAXATION !! Either use these arguments or eliminate them.
-//      ,unsigned int                a_IssueAge
+//      ,int                         a_IssueAge
 //      ,double                      a_Face
 //      ,mcenum_dbopt_7702           a_DBOpt
 //      ,std::vector<double> const&  a_q
diff --git a/input_realization.cpp b/input_realization.cpp
index 596cc84..5a87fa7 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -680,7 +680,7 @@ std::string Input::RealizeGeneralAccountRate()
         general_account_max_rate.assign(general_account_max_rate.size(), 0.12);
         }
 
-    for(unsigned int j = 0; j < general_account_max_rate.size(); ++j)
+    for(int j = 0; j < lmi::ssize(general_account_max_rate); ++j)
         {
         if(general_account_max_rate[j] < 
GeneralAccountRateRealized_[j].value())
             {
@@ -704,7 +704,7 @@ std::string Input::RealizeGeneralAccountRate()
         {
         return "";
         }
-    for(unsigned int j = 0; j < general_account_max_rate.size(); ++j)
+    for(int j = 0; j < lmi::ssize(general_account_max_rate); ++j)
         {
         if(GeneralAccountRateRealized_[j].value() < guar_int)
             {
diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 8e15351..bc2943b 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -31,6 +31,7 @@
 #include "input_sequence_aux.hpp"       // extract_keys_from_string_map()
 #include "mvc_controller.hpp"
 #include "numeric_io_cast.hpp"
+#include "ssize_lmi.hpp"
 #include "value_cast.hpp"
 #include "wx_new.hpp"
 #include "wx_utility.hpp"
@@ -85,7 +86,7 @@ choice_value const duration_mode_choice_values[] =
     {e_maturity,         "until maturity"},    // e_maturity must be last
   };
 
-unsigned int const duration_mode_choices = sizeof(duration_mode_choice_values) 
/ sizeof(choice_value);
+int const duration_mode_choices = sizeof(duration_mode_choice_values) / 
sizeof(choice_value);
 
 DurationModeChoice::DurationModeChoice(wxWindow* parent)
 {
@@ -155,7 +156,7 @@ duration_mode DurationModeChoice::value() const
     int const sel = GetSelection();
 
     LMI_ASSERT(0 <= sel);
-    LMI_ASSERT(sel < static_cast<int>(duration_mode_choices));
+    LMI_ASSERT(sel < duration_mode_choices);
 
     return duration_mode_choice_values[sel].mode;
 }
@@ -428,7 +429,7 @@ void InputSequenceEditor::sequence(InputSequence const& s)
 
     std::vector<ValueInterval> const& intervals = s.intervals();
 
-    for(unsigned int i = 0; i < intervals.size(); ++i)
+    for(int i = 0; i < lmi::ssize(intervals); ++i)
         {
         ValueInterval const& data = intervals[i];
 
diff --git a/interest_rates.cpp b/interest_rates.cpp
index 1b8a289..d6e233e 100644
--- a/interest_rates.cpp
+++ b/interest_rates.cpp
@@ -30,6 +30,7 @@
 #include "dbnames.hpp"
 #include "math_functions.hpp"           // assign_midpoint()
 #include "miscellany.hpp"               // each_equal()
+#include "ssize_lmi.hpp"
 #include "yare_input.hpp"
 
 #include <algorithm>                    // max(), copy()
@@ -183,7 +184,7 @@ void convert_interest_rates
     ,double                     fee
     )
 {
-    unsigned int const length = annual_gross_rate.size();
+    int const length = lmi::ssize(annual_gross_rate);
     annual_net_rate .resize(length);
     monthly_net_rate.resize(length);
 
@@ -193,7 +194,7 @@ void convert_interest_rates
     double previous_annual_gross_rate = 0.0;
     double previous_spread            = 0.0;
     double previous_floor             = 0.0;
-    for(unsigned int j = 0; j < length; ++j)
+    for(int j = 0; j < length; ++j)
         {
         if
             (
@@ -334,10 +335,7 @@ void InterestRates::Initialize(BasicValues const& v)
         // TODO ?? At least for the antediluvian branch, the vector in
         // the input class has an inappropriate size. Truncating it
         // with std::transform() here is far too tricky.
-        LMI_ASSERT
-            (   ExtraSepAcctCharge_.size()
-            ==  static_cast<unsigned int>(v.Database_->length())
-            );
+        LMI_ASSERT(lmi::ssize(ExtraSepAcctCharge_) == v.Database_->length());
 // Not reliably true:
 //        LMI_ASSERT
 //            (   ExtraSepAcctCharge_.size()
@@ -412,7 +410,6 @@ void InterestRates::Initialize(BasicValues const& v)
     Initialize7702Rates();
 
     // Paranoid check.
-    unsigned int z = static_cast<unsigned int>(Length_);
     for(int i = mce_annual_rate; i < mc_n_rate_periods; ++i)
         {
         for(int j = mce_gen_curr; j < mc_n_gen_bases; ++j)
@@ -420,19 +417,19 @@ void InterestRates::Initialize(BasicValues const& v)
             // The next line gets executed more than once with
             // identical semantics, but it's cheap, and writing it
             // to avoid that little problem would make it unclear.
-            LMI_ASSERT(z == GenAcctGrossRate_           [j]   .size());
-            LMI_ASSERT(z == GenAcctNetRate_          [i][j]   .size());
+            LMI_ASSERT(Length_ == lmi::ssize(GenAcctGrossRate_           [j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(GenAcctNetRate_          [i][j]   
));
             for(int k = mce_sep_full; k < mc_n_sep_bases; ++k)
                 {
-                LMI_ASSERT(z == SepAcctGrossRate_          [k].size());
-                LMI_ASSERT(z == SepAcctNetRate_      [i][j][k].size());
+                LMI_ASSERT(Length_ == lmi::ssize(SepAcctGrossRate_          
[k]));
+                LMI_ASSERT(Length_ == lmi::ssize(SepAcctNetRate_      
[i][j][k]));
                 }
-            LMI_ASSERT(z == RegLnCredRate_           [i][j]   .size());
-            LMI_ASSERT(z == RegLnDueRate_            [i][j]   .size());
-            LMI_ASSERT(z == PrfLnCredRate_           [i][j]   .size());
-            LMI_ASSERT(z == PrfLnDueRate_            [i][j]   .size());
-            LMI_ASSERT(z == HoneymoonValueRate_      [i][j]   .size());
-            LMI_ASSERT(z == PostHoneymoonGenAcctRate_[i][j]   .size());
+            LMI_ASSERT(Length_ == lmi::ssize(RegLnCredRate_           [i][j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(RegLnDueRate_            [i][j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(PrfLnCredRate_           [i][j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(PrfLnDueRate_            [i][j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(HoneymoonValueRate_      [i][j]   
));
+            LMI_ASSERT(Length_ == lmi::ssize(PostHoneymoonGenAcctRate_[i][j]   
));
             }
         }
 }
diff --git a/ledger_invariant.cpp b/ledger_invariant.cpp
index c354215..0b1d2b1 100644
--- a/ledger_invariant.cpp
+++ b/ledger_invariant.cpp
@@ -45,6 +45,7 @@
 #include "outlay.hpp"
 #include "premium_tax.hpp"
 #include "product_data.hpp"
+#include "ssize_lmi.hpp"
 
 #include <algorithm>
 #include <ostream>
@@ -568,7 +569,7 @@ void LedgerInvariant::Init(BasicValues const* b)
     int const NumberOfFunds = 30; // DEPRECATED
     int expected_number_of_funds = std::max(number_of_funds, NumberOfFunds);
     std::vector<double> v(b->yare_input_.FundAllocations);
-    if(v.size() < static_cast<unsigned int>(expected_number_of_funds))
+    if(lmi::ssize(v) < expected_number_of_funds)
         {
         v.insert(v.end(), expected_number_of_funds - v.size(), 0.0);
         }
diff --git a/ledger_xml_io.cpp b/ledger_xml_io.cpp
index bcf6d86..ec0a14a 100644
--- a/ledger_xml_io.cpp
+++ b/ledger_xml_io.cpp
@@ -38,6 +38,7 @@
 #include "miscellany.hpp"               // each_equal(), 
ios_out_trunc_binary(), lmi_array_size()
 #include "oecumenic_enumerations.hpp"
 #include "path_utility.hpp"             // fs::path inserter
+#include "ssize_lmi.hpp"
 #include "value_cast.hpp"
 #include "version.hpp"
 #include "xml_lmi.hpp"
@@ -808,7 +809,7 @@ void Ledger::write(xml::element& x) const
         std::vector<std::string> const& v = j.second;
 // TODO ?? InforceLives shows an extra value past the end; should it
 // be truncated here?
-        for(unsigned int k = 0; k < v.size(); ++k)
+        for(int k = 0; k < lmi::ssize(v); ++k)
             {
             xml::element duration("duration");
             xml_lmi::set_attr(duration, "number", 
value_cast<std::string>(k).c_str());
@@ -892,12 +893,12 @@ void Ledger::write(xml::element& x) const
             }
         ofs << '\n';
 
-        for(unsigned int i = 0; i < static_cast<unsigned int>(GetMaxLength()); 
++i)
+        for(int i = 0; i < GetMaxLength(); ++i)
             {
             for(auto const& j : stringvectors)
                 {
                 std::vector<std::string> const& v = j.second;
-                if(i < v.size())
+                if(i < lmi::ssize(v))
                     {
                     ofs << v[i] << '\t';
                     }
diff --git a/main_cgi.cpp b/main_cgi.cpp
index 2c06927..60420a5 100644
--- a/main_cgi.cpp
+++ b/main_cgi.cpp
@@ -43,6 +43,7 @@
 #include "miscellany.hpp"
 #include "path_utility.hpp"
 #include "platform_dependent.hpp"       // putenv() [GWC]
+#include "ssize_lmi.hpp"
 #include "timer.hpp"
 #include "value_cast.hpp"
 
@@ -615,7 +616,7 @@ void ShowCensusOutput
                 ;
             }
 
-        for(unsigned int j = 0; j < headers.size(); ++j)
+        for(int j = 0; j < lmi::ssize(headers); ++j)
             {
             input[headers[j]] = values[j];
             }
diff --git a/mec_server.cpp b/mec_server.cpp
index 64c902b..10e7f46 100644
--- a/mec_server.cpp
+++ b/mec_server.cpp
@@ -45,6 +45,7 @@
 #include "premium_tax.hpp"
 #include "product_data.hpp"
 #include "round_to.hpp"
+#include "ssize_lmi.hpp"
 #include "stratified_algorithms.hpp"    // TieredGrossToNet()
 #include "stratified_charges.hpp"
 #include "timer.hpp"
@@ -320,7 +321,7 @@ mec_state test_one_days_7702A_transactions
     double const LoadTarget = target_sales_load[InforceYear] + 
target_premium_load[InforceYear] + dac_tax_load[InforceYear] + premium_tax_load;
     double const LoadExcess = excess_sales_load[InforceYear] + 
excess_premium_load[InforceYear] + dac_tax_load[InforceYear] + premium_tax_load;
 
-    LMI_ASSERT(static_cast<unsigned int>(InforceContractYear) < 
input.BenefitHistoryRealized().size());
+    LMI_ASSERT(InforceContractYear < 
lmi::ssize(input.BenefitHistoryRealized()));
     double const old_benefit_amount = 
input.BenefitHistoryRealized()[InforceContractYear];
 
     double const total_1035_amount = round_max_premium
diff --git a/mortality_rates_test.cpp b/mortality_rates_test.cpp
index 861501c..f962649 100644
--- a/mortality_rates_test.cpp
+++ b/mortality_rates_test.cpp
@@ -26,6 +26,7 @@
 #include "assert_lmi.hpp"
 #include "materially_equal.hpp"
 #include "math_functions.hpp"
+#include "ssize_lmi.hpp"
 #include "test_tools.hpp"
 
 namespace
@@ -149,7 +150,7 @@ void mortality_rates_test::test_4095_4096ths()
 
 void mortality_rates_test::test_annual_to_monthly_conversion()
 {
-    for(unsigned int j = 0; j < annual_rates().size(); ++j)
+    for(int j = 0; j < lmi::ssize(annual_rates()); ++j)
         {
         BOOST_TEST
             (materially_equal
diff --git a/multiple_cell_document.cpp b/multiple_cell_document.cpp
index 17e82e1..e0e2e68 100644
--- a/multiple_cell_document.cpp
+++ b/multiple_cell_document.cpp
@@ -26,6 +26,7 @@
 #include "alert.hpp"
 #include "assert_lmi.hpp"
 #include "data_directory.hpp"           // AddDataDir()
+#include "ssize_lmi.hpp"
 #include "value_cast.hpp"
 #include "xml_lmi.hpp"
 
@@ -254,7 +255,7 @@ void multiple_cell_document::parse_v0(xml_lmi::dom_parser 
const& parser)
         }
     std::string const str_n_classes = xml_lmi::get_content(*i);
     LMI_ASSERT(!str_n_classes.empty());
-    unsigned int number_of_classes = value_cast<unsigned int>(str_n_classes);
+    int number_of_classes = value_cast<int>(str_n_classes);
 
     // Parameters for each class.
     class_parms_.clear();
@@ -292,12 +293,12 @@ void multiple_cell_document::parse_v0(xml_lmi::dom_parser 
const& parser)
             *i >> temp;
             }
         class_parms_.push_back(temp);
-        if(class_parms_.size() == number_of_classes)
+        if(lmi::ssize(class_parms_) == number_of_classes)
             {
             break;
             }
         }
-    if(class_parms_.size() != number_of_classes)
+    if(lmi::ssize(class_parms_) != number_of_classes)
         {
         alarum()
             << "Number of classes read is "
@@ -326,7 +327,7 @@ void multiple_cell_document::parse_v0(xml_lmi::dom_parser 
const& parser)
         }
     std::string const str_n_cells = xml_lmi::get_content(*i);
     LMI_ASSERT(!str_n_cells.empty());
-    unsigned int number_of_cells = value_cast<unsigned int>(str_n_cells);
+    int number_of_cells = value_cast<int>(str_n_cells);
 
     // Parameters for each cell.
     cell_parms_.clear();
@@ -345,12 +346,12 @@ void multiple_cell_document::parse_v0(xml_lmi::dom_parser 
const& parser)
             << " lives."
             << std::flush
             ;
-        if(cell_parms_.size() == number_of_cells)
+        if(lmi::ssize(cell_parms_) == number_of_cells)
             {
             break;
             }
         }
-    if(cell_parms_.size() != number_of_cells)
+    if(lmi::ssize(cell_parms_) != number_of_cells)
         {
         alarum()
             << "Number of individuals read is "
diff --git a/timer_test.cpp b/timer_test.cpp
index 729c82e..fce6a61 100644
--- a/timer_test.cpp
+++ b/timer_test.cpp
@@ -36,9 +36,9 @@ inline void do_nothing()
 void foo()
 {
     double volatile d;
-    for(unsigned int j = 0; j < 100; ++j)
+    for(int j = 0; j < 100; ++j)
         {
-        d = std::log10(1U + j * j);
+        d = std::log10(1 + j * j);
         stifle_warning_for_unused_value(d);
         }
 }



reply via email to

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