lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 036a6b0 5/5: Modernize for statements


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 036a6b0 5/5: Modernize for statements
Date: Wed, 25 Jan 2017 01:45:54 +0000 (UTC)

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

    Modernize for statements
---
 group_values.cpp         |    9 +++++----
 loads.cpp                |    9 ++-------
 main_cgi.cpp             |   18 ++++++++----------
 mc_enum_aux.hpp          |    5 ++---
 preferences_model.cpp    |   12 +++++-------
 rounding_view_editor.cpp |   18 +++++-------------
 6 files changed, 27 insertions(+), 44 deletions(-)

diff --git a/group_values.cpp b/group_values.cpp
index d6fc01e..4715ed7 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -250,15 +250,14 @@ census_run_result run_census_in_parallel::operator()
 
     ledger_emitter emitter(file, emission);
 
-    std::vector<Input>::const_iterator ip;
     std::vector<std::shared_ptr<AccountValue> > cell_values;
     std::vector<mcenum_run_basis> const& RunBases = composite.GetRunBases();
 
-    int j = 0;
     int const first_cell_inforce_year  = 
value_cast<int>((*cells.begin())["InforceYear"].str());
     int const first_cell_inforce_month = 
value_cast<int>((*cells.begin())["InforceMonth"].str());
     cell_values.reserve(cells.size());
-    for(ip = cells.begin(); ip != cells.end(); ++ip, ++j)
+    int j = 0;
+    for(auto const& ip : cells)
         {
         // This condition need be written only once, here, because
         // subsequently 'cell_values' (which reflects the condition)
@@ -267,7 +266,7 @@ census_run_result run_census_in_parallel::operator()
             {
             { // Begin fenv_guard scope.
             fenv_guard fg;
-            std::shared_ptr<AccountValue> av(new AccountValue(*ip));
+            std::shared_ptr<AccountValue> av(new AccountValue(ip));
             std::string const name(cells[j]["InsuredName"].str());
             // Indexing: here, j is an index into cells, not cell_values.
             av->SetDebugFilename
@@ -309,6 +308,8 @@ census_run_result run_census_in_parallel::operator()
             result.completed_normally_ = false;
             goto done;
             }
+
+        ++j;
         } // End for.
     meter->culminate();
     if(cell_values.empty())
diff --git a/loads.cpp b/loads.cpp
index 120301d..724cb6c 100644
--- a/loads.cpp
+++ b/loads.cpp
@@ -201,14 +201,9 @@ void Loads::Calculate(load_details const& details)
                 );
 #endif // 0
             separate_account_load_[j] += extra_asset_comp;
-            std::vector<double>::iterator k;
-            for
-                (k = separate_account_load_[j].begin()
-                ;k != separate_account_load_[j].end()
-                ;++k
-                )
+            for(auto& k : separate_account_load_[j])
                 {
-                *k = details.round_interest_rate_(*k);
+                k = details.round_interest_rate_(k);
                 }
             }
         }
diff --git a/main_cgi.cpp b/main_cgi.cpp
index e2c786a..f807fa8 100644
--- a/main_cgi.cpp
+++ b/main_cgi.cpp
@@ -625,24 +625,22 @@ void ShowCensusOutput
         lives.push_back(input);
         }
 
-    std::vector<std::string>::iterator h;
-    std::vector<Input>::iterator i;
-
     // Print census as HTML table.
     std::cout << "Census:<BR><BR>";
     std::cout << "<TABLE>";
     std::cout << "<TR>";
-    for(h = headers.begin(); h != headers.end(); ++h)
+
+    for(auto const& h : headers)
         {
-        std::cout << "<TD>" << *h << "</TD>";
+        std::cout << "<TD>" << h << "</TD>";
         }
     std::cout << "</TR>";
-    for(i = lives.begin(); i != lives.end(); ++i)
+    for(auto const& i : lives)
         {
         std::cout << "<TR>";
-        for(h = headers.begin(); h != headers.end(); ++h)
+        for(auto const& h : headers)
             {
-            std::cout << "<TD>" << (*i)[*h] << "</TD>";
+            std::cout << "<TD>" << i[h] << "</TD>";
             }
         std::cout << "</TR>";
         }
@@ -675,9 +673,9 @@ void ShowCensusOutput
     // each life in order to get the composite.
     if(show_each_life)
         {
-        for(i = lives.begin(); i != lives.end(); ++i)
+        for(auto const& i : lives)
             {
-            ShowIllusOutput(*i);
+            ShowIllusOutput(i);
             }
         }
 }
diff --git a/mc_enum_aux.hpp b/mc_enum_aux.hpp
index 7ebc474..b0ef6c5 100644
--- a/mc_enum_aux.hpp
+++ b/mc_enum_aux.hpp
@@ -35,10 +35,9 @@ std::vector<std::string> mc_e_vector_to_string_vector
     )
 {
     std::vector<std::string> vs;
-    typename std::vector<mc_enum<T> >::const_iterator ve_i;
-    for(ve_i = ve.begin(); ve_i != ve.end(); ++ve_i)
+    for(auto const& i : ve)
         {
-        vs.push_back(ve_i->str());
+        vs.push_back(i.str());
         }
     return vs;
 }
diff --git a/preferences_model.cpp b/preferences_model.cpp
index 72cc6fd..247ea8c 100644
--- a/preferences_model.cpp
+++ b/preferences_model.cpp
@@ -229,10 +229,9 @@ bool PreferencesModel::IsModified() const
 {
     PreferencesModel unchanged;
     configurable_settings const& z = configurable_settings::instance();
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
+    for(auto const& i : member_names())
         {
-        if(operator[](*i) != unchanged[*i])
+        if(operator[](i) != unchanged[i])
             {
             return true;
             }
@@ -278,14 +277,13 @@ void PreferencesModel::Load()
 std::string PreferencesModel::string_of_column_names() const
 {
     std::ostringstream oss;
-    std::vector<std::string>::const_iterator i;
-    for(i = member_names().begin(); i != member_names().end(); ++i)
+    for(auto const& i : member_names())
         {
-        if(!is_calculation_summary_column_name(*i))
+        if(!is_calculation_summary_column_name(i))
             {
             continue;
             }
-        std::string const column = operator[](*i).str();
+        std::string const column = operator[](i).str();
         if(column != empty_column_name)
             {
             oss << column << " ";
diff --git a/rounding_view_editor.cpp b/rounding_view_editor.cpp
index 207f326..d03f1a7 100644
--- a/rounding_view_editor.cpp
+++ b/rounding_view_editor.cpp
@@ -88,25 +88,17 @@ button_bitmaps const& all_button_bitmaps()
         states[e_state_selected] = "_selected";
 
         wxXmlResource& xml_resources = *wxXmlResource::Get();
-        for
-            (style_names::const_iterator li = styles.begin()
-            ;li != styles.end()
-            ;++li
-            )
+        for(auto const& li : styles)
             {
-            for
-                (state_names::const_iterator ti = states.begin()
-                ;ti != states.end()
-                ;++ti
-                )
+            for(auto const& ti : states)
                 {
                 std::ostringstream oss;
                 oss
                     << "rnd_"
-                    << li->second
-                    << ti->second
+                    << li.second
+                    << ti.second
                     ;
-                bitmaps[std::make_pair(li->first, ti->first)] =
+                bitmaps[std::make_pair(li.first, ti.first)] =
                     xml_resources.LoadBitmap(oss.str());
                 }
             }



reply via email to

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