[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 78614fe 2/2: Modernize for statements
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 78614fe 2/2: Modernize for statements |
Date: |
Mon, 16 Jan 2017 15:24:17 +0000 (UTC) |
branch: master
commit 78614fe0c37678a28ccbb9439d887121b0aeeb7f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Modernize for statements
---
any_member.hpp | 19 +++++--------
dbnames.cpp | 13 ++++-----
gpt_input.cpp | 10 +++----
group_quote_pdf_gen_wx.cpp | 27 +++++++++----------
icon_monger.cpp | 3 +--
ihs_acctval.cpp | 10 ++-----
input_harmonization.cpp | 27 +++++++++----------
input_realization.cpp | 25 ++++++------------
main_cli.cpp | 7 ++---
main_wx_test.cpp | 21 +++++++--------
mec_input.cpp | 10 +++----
miscellany.cpp | 5 ++--
mvc_controller.cpp | 60 +++++++++++++++---------------------------
mvc_model.cpp | 7 +++--
policy_document.cpp | 18 +++----------
policy_view.cpp | 32 ++++++----------------
preferences_model.cpp | 27 +++++++++----------
product_data.cpp | 5 ++--
regex_test.cpp | 10 +++----
rounding_document.cpp | 10 +++----
rounding_view.cpp | 32 ++++++----------------
skeleton.cpp | 26 ++++++++----------
tier_document.cpp | 6 ++---
tier_view.cpp | 4 +--
view_ex.tpp | 4 +--
wx_test_about_version.cpp | 27 +++++++++----------
wx_test_input_sequences.cpp | 4 +--
wx_test_input_validation.cpp | 4 +--
wx_test_paste_census.cpp | 3 +--
wx_utility.cpp | 4 +--
30 files changed, 167 insertions(+), 293 deletions(-)
diff --git a/any_member.hpp b/any_member.hpp
index d5fbef2..75b600b 100644
--- a/any_member.hpp
+++ b/any_member.hpp
@@ -634,9 +634,8 @@ void MemberSymbolTable<ClassType>::ascribe
ClassType* class_object = static_cast<ClassType*>(this);
map_.insert(member_pair_type(s, any_member<ClassType>(class_object, p2m)));
- typedef std::vector<std::string>::iterator svi;
// TODO ?? This would appear to be O(N^2).
- svi i = std::lower_bound(member_names_.begin(), member_names_.end(), s);
+ auto i = std::lower_bound(member_names_.begin(), member_names_.end(), s);
member_names_.insert(i, s);
}
@@ -645,10 +644,9 @@ MemberSymbolTable<ClassType>&
MemberSymbolTable<ClassType>::assign
(MemberSymbolTable<ClassType> const& z
)
{
- typedef std::vector<std::string>::const_iterator mnci;
- for(mnci i = member_names().begin(); i != member_names().end(); ++i)
+ for(auto const& i : member_names())
{
- operator[](*i) = z[*i];
+ operator[](i) = z[i];
}
return *this;
}
@@ -658,10 +656,9 @@ bool MemberSymbolTable<ClassType>::equals
(MemberSymbolTable<ClassType> const& z
) const
{
- typedef std::vector<std::string>::const_iterator mnci;
- for(mnci i = member_names().begin(); i != member_names().end(); ++i)
+ for(auto const& i : member_names())
{
- if(z[*i] != operator[](*i))
+ if(z[i] != operator[](i))
{
return false;
}
@@ -687,11 +684,9 @@ std::map<std::string,std::string> member_state
)
{
std::map<std::string,std::string> z;
- std::vector<std::string> const& names = object.member_names();
- typedef std::vector<std::string>::const_iterator mnci;
- for(mnci i = names.begin(); i != names.end(); ++i)
+ for(auto const& i : object.member_names())
{
- z[*i] = object[*i].str();
+ z[i] = object[i].str();
}
return z;
}
diff --git a/dbnames.cpp b/dbnames.cpp
index 403b1aa..6751879 100644
--- a/dbnames.cpp
+++ b/dbnames.cpp
@@ -85,14 +85,12 @@ std::vector<db_names> const& static_get_db_names()
return v;
}
-std::map<std::string,int> static_get_short_names()
+std::map<std::string,int> short_name_to_key_map()
{
std::map<std::string,int> m;
- static std::vector<db_names> const names = static_get_db_names();
- typedef std::vector<db_names>::const_iterator vdbnci;
- for(vdbnci i = names.begin(); i != names.end(); ++i)
+ for(auto const& i : static_get_db_names())
{
- m[i->ShortName] = i->Idx;
+ m[i.ShortName] = i.Idx;
}
return m;
}
@@ -106,14 +104,13 @@ std::vector<db_names> const& GetDBNames()
int db_key_from_name(std::string const& name)
{
- static std::map<std::string,int> const m = static_get_short_names();
+ static std::map<std::string,int> const m = short_name_to_key_map();
return map_lookup(m, name);
}
std::string db_name_from_key(int key)
{
- static std::vector<db_names> const names = static_get_db_names();
LMI_ASSERT(0 <= key && key < DB_LAST);
- return names[key].ShortName;
+ return static_get_db_names()[key].ShortName;
}
diff --git a/gpt_input.cpp b/gpt_input.cpp
index 1efe3fa..a345d32 100644
--- a/gpt_input.cpp
+++ b/gpt_input.cpp
@@ -576,18 +576,14 @@ std::vector<std::string>
gpt_input::RealizeAllSequenceInput(bool report_errors)
if(report_errors)
{
- for
- (std::vector<std::string>::iterator i = s.begin()
- ;i != s.end()
- ;++i
- )
+ for(auto const& i : s)
{
std::ostringstream oss;
bool diagnostics_present = false;
- if(!i->empty())
+ if(!i.empty())
{
diagnostics_present = true;
- oss << (*i) << "\n";
+ oss << i << "\n";
}
if(diagnostics_present)
{
diff --git a/group_quote_pdf_gen_wx.cpp b/group_quote_pdf_gen_wx.cpp
index 810cf38..515ab72 100644
--- a/group_quote_pdf_gen_wx.cpp
+++ b/group_quote_pdf_gen_wx.cpp
@@ -77,14 +77,14 @@ wxString escape_for_html_elem(std::string const& s)
wxString z;
z.reserve(u.length());
- for(wxString::const_iterator i = u.begin(); i != u.end(); ++i)
+ for(auto const& i : u)
{
- switch((*i).GetValue())
+ switch(i.GetValue())
{
case '<': z += "<" ; break;
case '>': z += ">" ; break;
case '&': z += "&"; break;
- default : z += *i ;
+ default : z += i ;
}
}
return z;
@@ -247,36 +247,35 @@ std::vector<extra_summary_field>
parse_extra_report_fields(std::string const& s)
std::vector<extra_summary_field> fields;
fields.reserve(lines.size());
- typedef std::vector<std::string>::const_iterator vsci;
- for(vsci i = lines.begin(); i != lines.end(); ++i)
+ for(auto const& i : lines)
{
// Ignore the empty or blank lines, they could be added for readability
// reasons and this also deals with the problem of split_into_lines()
// returning a vector of a single empty line even if the source string
// is entirely empty.
- if(i->find_first_not_of(' ') == std::string::npos)
+ if(i.find_first_not_of(' ') == std::string::npos)
{
continue;
}
extra_summary_field field;
- std::string::size_type const pos_colon = i->find(':');
+ std::string::size_type const pos_colon = i.find(':');
// Notice that substr() call is correct even if there is no colon in
// this line, i.e. pos_colon == npos.
- field.name = i->substr(0, pos_colon);
+ field.name = i.substr(0, pos_colon);
if(pos_colon != std::string::npos)
{
// Skip any spaces after the colon as this is what would be
// normally expected by the user.
std::string::size_type const
- pos_value = i->find_first_not_of(' ', pos_colon + 1);
+ pos_value = i.find_first_not_of(' ', pos_colon + 1);
if(pos_value != std::string::npos)
{
- field.value = i->substr(pos_value);
+ field.value = i.substr(pos_value);
}
}
// else: If there is no colon or nothing but space after it, just leave
@@ -1045,10 +1044,9 @@ void
group_quote_pdf_generator_wx::do_generate_pdf(wxPdfDC& pdf_dc)
int current_page = 1;
- typedef std::vector<row_data>::const_iterator rdci;
- for(rdci i = rows_.begin(); i != rows_.end(); ++i)
+ for(auto const& i : rows_)
{
- table_gen.output_row(&pos_y, i->values);
+ table_gen.output_row(&pos_y, i.values);
if(last_row_y <= pos_y)
{
@@ -1235,8 +1233,7 @@ void group_quote_pdf_generator_wx::output_document_header
std::vector<extra_summary_field> const& f = report_data_.extra_fields_;
fields.insert(fields.end(), f.begin(), f.end());
- typedef std::vector<extra_summary_field>::const_iterator esfci;
- for(esfci i = fields.begin(); i != fields.end();)
+ for(auto i = fields.begin(); i != fields.end(); ++i)
{
// Start a new table row and ensure it will be closed.
open_and_ensure_closing_tag tag_tr(summary_html, "tr");
diff --git a/icon_monger.cpp b/icon_monger.cpp
index ab5f948..6f2375c 100644
--- a/icon_monger.cpp
+++ b/icon_monger.cpp
@@ -153,8 +153,7 @@ wxBitmap icon_monger::CreateBitmap
bool is_builtin = 0 == icon_name.find("wxART_");
if(is_builtin)
{
- typedef std::map<wxArtID,std::string>::const_iterator mci;
- mci const i = icon_names_by_wx_id_.find(icon_name);
+ auto const& i = icon_names_by_wx_id_.find(icon_name);
if(i == icon_names_by_wx_id_.end())
{
// This is not an error as not all wxART id's have lmi overrides,
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 1749fd7..eefc2cd 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -51,7 +51,6 @@
#include <algorithm>
#include <cmath>
#include <functional>
-#include <iterator>
#include <limits>
#include <numeric>
#include <string>
@@ -317,14 +316,9 @@ double AccountValue::RunAllApplicableBases()
// on the solve basis.
}
// Run all bases, current first.
- std::vector<mcenum_run_basis> const& run_bases = ledger_->GetRunBases();
- for
- (std::vector<mcenum_run_basis>::const_iterator b = run_bases.begin()
- ;b != run_bases.end()
- ;++b
- )
+ for(auto const& b : ledger_->GetRunBases())
{
- RunOneBasis(*b);
+ RunOneBasis(b);
}
return z;
}
diff --git a/input_harmonization.cpp b/input_harmonization.cpp
index 7400db4..672b1b8 100644
--- a/input_harmonization.cpp
+++ b/input_harmonization.cpp
@@ -844,21 +844,20 @@ false // Silly workaround for now.
&& 0.0 < InforceSeparateAccountValue.value()
;
- typedef std::vector<mcenum_report_column>::const_iterator vrci;
- for(vrci i = weird_report_columns.begin(); i !=
weird_report_columns.end(); ++i)
+ for(auto const& i : weird_report_columns)
{
- SupplementalReportColumn00.allow(*i, enable_weirdness);
- SupplementalReportColumn01.allow(*i, enable_weirdness);
- SupplementalReportColumn02.allow(*i, enable_weirdness);
- SupplementalReportColumn03.allow(*i, enable_weirdness);
- SupplementalReportColumn04.allow(*i, enable_weirdness);
- SupplementalReportColumn05.allow(*i, enable_weirdness);
- SupplementalReportColumn06.allow(*i, enable_weirdness);
- SupplementalReportColumn07.allow(*i, enable_weirdness);
- SupplementalReportColumn08.allow(*i, enable_weirdness);
- SupplementalReportColumn09.allow(*i, enable_weirdness);
- SupplementalReportColumn10.allow(*i, enable_weirdness);
- SupplementalReportColumn11.allow(*i, enable_weirdness);
+ SupplementalReportColumn00.allow(i, enable_weirdness);
+ SupplementalReportColumn01.allow(i, enable_weirdness);
+ SupplementalReportColumn02.allow(i, enable_weirdness);
+ SupplementalReportColumn03.allow(i, enable_weirdness);
+ SupplementalReportColumn04.allow(i, enable_weirdness);
+ SupplementalReportColumn05.allow(i, enable_weirdness);
+ SupplementalReportColumn06.allow(i, enable_weirdness);
+ SupplementalReportColumn07.allow(i, enable_weirdness);
+ SupplementalReportColumn08.allow(i, enable_weirdness);
+ SupplementalReportColumn09.allow(i, enable_weirdness);
+ SupplementalReportColumn10.allow(i, enable_weirdness);
+ SupplementalReportColumn11.allow(i, enable_weirdness);
}
}
diff --git a/input_realization.cpp b/input_realization.cpp
index 41b10f7..0098d1f 100644
--- a/input_realization.cpp
+++ b/input_realization.cpp
@@ -157,10 +157,9 @@ Input::permissible_specified_amount_strategy_keywords()
// std::map<std::string,std::string> permissible_keywords = all_keywords;
std::map<std::string,std::string> permissible_keywords;
// Don't use initialization--we want this to happen every time [6.7].
- typedef std::map<std::string,std::string>::const_iterator smci;
- for(smci i = all_keywords.begin(); i != all_keywords.end(); ++i)
+ for(auto const& i : all_keywords)
{
- permissible_keywords.insert(*i);
+ permissible_keywords.insert(i);
}
bool specified_amount_indeterminate = mce_solve_specamt == SolveType;
@@ -232,18 +231,14 @@ std::vector<std::string>
Input::RealizeAllSequenceInput(bool report_errors)
if(report_errors)
{
- for
- (std::vector<std::string>::iterator i = s.begin()
- ;i != s.end()
- ;++i
- )
+ for(auto const& i : s)
{
std::ostringstream oss;
bool diagnostics_present = false;
- if(!i->empty())
+ if(!i.empty())
{
diagnostics_present = true;
- oss << (*i) << "\n";
+ oss << i << "\n";
}
if(diagnostics_present)
{
@@ -831,20 +826,16 @@ std::string Input::RealizeWithdrawal()
else
{
double lowest_allowed_withdrawal = database_->Query(DB_MinWd);
- for
- (std::vector<tnr_unrestricted_double>::iterator i =
WithdrawalRealized_.begin()
- ;i < WithdrawalRealized_.end()
- ;++i
- )
+ for(auto const& i : WithdrawalRealized_)
{
- if(0.0 < i->value() && i->value() < lowest_allowed_withdrawal)
+ if(0.0 < i.value() && i.value() < lowest_allowed_withdrawal)
{
std::ostringstream oss;
oss
<< "Minimum withdrawal is "
<< lowest_allowed_withdrawal
<< "; "
- << *i
+ << i
<< " is too low."
;
return oss.str();
diff --git a/main_cli.cpp b/main_cli.cpp
index 707caeb..cb59d2d 100644
--- a/main_cli.cpp
+++ b/main_cli.cpp
@@ -55,7 +55,6 @@
#include <cstdio> // std::printf()
#include <ios>
#include <iostream>
-#include <iterator>
#include <ostream>
#include <stdexcept>
#include <string>
@@ -406,11 +405,9 @@ void process_command_line(int argc, char* argv[])
{
getopt_long.usage();
std::cout << "Suboptions for '--emit':\n";
- std::vector<std::string> const& v = allowed_strings_emission();
- typedef std::vector<std::string>::const_iterator vsi;
- for(vsi i = v.begin(); i != v.end(); ++i)
+ for(auto const& i : allowed_strings_emission())
{
- std::cout << " " << *i << '\n';
+ std::cout << " " << i << '\n';
}
return;
}
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index f3d55b6..04b4ad7 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -269,12 +269,11 @@ void application_test::process_test_name(char const* name)
bool any_tests_matched = false;
- typedef std::vector<test_descriptor>::iterator tdi;
- for(tdi i = tests_.begin(); i != tests_.end(); ++i)
+ for(auto& i : tests_)
{
- if (wxString(i->get_name()).Matches(name))
+ if(wxString(i.get_name()).Matches(name))
{
- i->run = run;
+ i.run = run;
any_tests_matched = true;
}
}
@@ -452,21 +451,20 @@ TestsResults application_test::run()
TestsResults results;
- typedef std::vector<test_descriptor>::const_iterator ctdi;
- for(ctdi i = tests_.begin(); i != tests_.end(); ++i)
+ for(auto const& i : tests_)
{
- if ((run_all_ && i->run != run_no) || i->run == run_yes)
+ if ((run_all_ && i.run != run_no) || i.run == run_yes)
{
std::string error;
results.total++;
- char const* const name = i->get_name();
+ char const* const name = i.get_name();
try
{
wxPrintf("%s: started\n", name);
wxStopWatch sw;
- i->run_test();
+ i.run_test();
// Check that no messages were unexpectedly logged during this
// test execution.
wxLog::FlushActive();
@@ -522,10 +520,9 @@ void application_test::list_tests()
std::cout << "Available tests:\n";
- typedef std::vector<test_descriptor>::const_iterator ctdi;
- for(ctdi i = tests_.begin(); i != tests_.end(); ++i)
+ for(auto const& i : tests_)
{
- std::cout << '\t' << i->get_name() << '\n';
+ std::cout << '\t' << i.get_name() << '\n';
}
std::cout << tests_.size() << " test cases.\n";
diff --git a/mec_input.cpp b/mec_input.cpp
index f8a1446..0458184 100644
--- a/mec_input.cpp
+++ b/mec_input.cpp
@@ -522,18 +522,14 @@ std::vector<std::string>
mec_input::RealizeAllSequenceInput(bool report_errors)
if(report_errors)
{
- for
- (std::vector<std::string>::iterator i = s.begin()
- ;i != s.end()
- ;++i
- )
+ for(auto const& i : s)
{
std::ostringstream oss;
bool diagnostics_present = false;
- if(!i->empty())
+ if(!i.empty())
{
diagnostics_present = true;
- oss << (*i) << "\n";
+ oss << i << "\n";
}
if(diagnostics_present)
{
diff --git a/miscellany.cpp b/miscellany.cpp
index 852926f..56d991c 100644
--- a/miscellany.cpp
+++ b/miscellany.cpp
@@ -30,6 +30,7 @@
#include <ctime>
#include <fstream>
#include <istream>
+#include <iterator> // std::istreambuf_iterator
namespace
{
@@ -108,10 +109,8 @@ std::string htmlize(std::string const& raw_text)
std::string html;
html.reserve(raw_text.size());
- typedef std::string::const_iterator sci;
- for(sci i = raw_text.begin(); i != raw_text.end(); ++i)
+ for(auto const& c : raw_text)
{
- std::string::const_reference c = *i;
switch(c)
{
case '&': {html += "&";} break;
diff --git a/mvc_controller.cpp b/mvc_controller.cpp
index e8d175d..634a8ec 100644
--- a/mvc_controller.cpp
+++ b/mvc_controller.cpp
@@ -133,14 +133,12 @@ MvcController::MvcController
// Call ModelReference() to ensure that each Model entity is of a
// type derived from class datum_base.
- std::vector<std::string> const& mn = model_.Names();
- typedef std::vector<std::string>::const_iterator svci;
- for(svci i = mn.begin(); i != mn.end(); ++i)
+ for(auto const& i : model_.Names())
{
- ModelReference<datum_base>(*i);
- if(FindWindow(wxXmlResource::GetXRCID(i->c_str())))
+ ModelReference<datum_base>(i);
+ if(FindWindow(wxXmlResource::GetXRCID(i.c_str())))
{
- Bind(*i, transfer_data_[*i] = model_.Entity(*i).str());
+ Bind(i, transfer_data_[i] = model_.Entity(i).str());
}
}
@@ -178,10 +176,9 @@ void MvcController::Assimilate(std::string const&
name_to_ignore)
ConditionallyEnable();
- typedef std::map<std::string,std::string>::const_iterator smci;
- for(smci i = transfer_data_.begin(); i != transfer_data_.end(); ++i)
+ for(auto const& i : transfer_data_)
{
- std::string const& name = i->first;
+ std::string const& name = i.first;
std::string const& model_value = model_.Entity(name).str();
if(name == name_to_ignore || ModelAndViewValuesEquivalent(name))
{
@@ -212,11 +209,8 @@ wxBookCtrlBase const& MvcController::BookControl() const
void MvcController::ConditionallyEnable()
{
- typedef std::vector<wxWindow*>::const_iterator wvci;
- std::vector<wxWindow*> page_lineage = Lineage(&CurrentPage());
- for(wvci i = page_lineage.begin(); i != page_lineage.end(); ++i)
+ for(auto const& pw : Lineage(&CurrentPage()))
{
- wxWindow* pw = *i;
LMI_ASSERT(nullptr != pw);
Transferor* t = dynamic_cast<Transferor*>(pw->GetValidator());
if(t)
@@ -244,9 +238,8 @@ void MvcController::ConditionallyEnable()
// date ranges fail to work, and the observable symptom is quite
// spectacular.
- for(wvci i = lineage_.begin(); i != lineage_.end(); ++i)
+ for(auto const& pw : lineage_)
{
- wxWindow* pw = *i;
LMI_ASSERT(nullptr != pw);
Transferor* t = dynamic_cast<Transferor*>(pw->GetValidator());
if(t)
@@ -424,14 +417,11 @@ void MvcController::EnsureOptimalFocus()
}
SetFocus();
- typedef std::vector<wxWindow*>::const_iterator wvci;
- std::vector<wxWindow*> page_lineage = Lineage(&CurrentPage());
- for(wvci i = page_lineage.begin(); i != page_lineage.end(); ++i)
+ for(auto const& pw : Lineage(&CurrentPage()))
{
- wxWindow* w = *i;
- if(w && w->IsEnabled() && w->AcceptsFocus())
+ if(pw && pw->IsEnabled() && pw->AcceptsFocus())
{
- w->SetFocus();
+ pw->SetFocus();
break;
}
}
@@ -458,10 +448,8 @@ void MvcController::EnsureOptimalFocus()
void MvcController::Initialize()
{
- typedef std::vector<wxWindow*>::const_iterator wvci;
- for(wvci i = lineage_.begin(); i != lineage_.end(); ++i)
+ for(auto const& pw : lineage_)
{
- wxWindow* pw = *i;
LMI_ASSERT(nullptr != pw);
Transferor* t = dynamic_cast<Transferor*>(pw->GetValidator());
if(t)
@@ -521,20 +509,16 @@ void MvcController::RefocusLastFocusedWindow()
void MvcController::TestModelViewConsistency() const
{
- std::vector<std::string> const& mn = model_.Names();
- typedef std::vector<std::string>::const_iterator svci;
- for(svci i = mn.begin(); i != mn.end(); ++i)
+ for(auto const& i : model_.Names())
{
- if(!FindWindow(wxXmlResource::GetXRCID(i->c_str())))
+ if(!FindWindow(wxXmlResource::GetXRCID(i.c_str())))
{
- warning() << "No View entity matches '" << *i << "'.\n";
+ warning() << "No View entity matches '" << i << "'.\n";
}
}
- typedef std::vector<wxWindow*>::const_iterator wvci;
- for(wvci i = lineage_.begin(); i != lineage_.end(); ++i)
+ for(auto const& pw : lineage_)
{
- wxWindow* pw = *i;
if
( pw->AcceptsFocus()
&& !dynamic_cast<Transferor*>(pw->GetValidator())
@@ -823,11 +807,10 @@ void MvcController::UponUpdateUI(wxUpdateUIEvent& event)
DiagnosticsWindow().SetLabel("");
std::vector<std::string> control_changes;
std::string const name_to_ignore = NameOfControlToDeferEvaluating();
- typedef std::map<std::string,std::string>::const_iterator smci;
- for(smci i = transfer_data_.begin(); i != transfer_data_.end(); ++i)
+ for(auto const& i : transfer_data_)
{
- std::string const& name = i->first;
- std::string const& view_value = i->second;
+ std::string const& name = i.first;
+ std::string const& view_value = i.second;
std::string const& model_value = model_.Entity(name).str();
if(name == name_to_ignore || ModelAndViewValuesEquivalent(name))
{
@@ -854,10 +837,9 @@ void MvcController::UponUpdateUI(wxUpdateUIEvent& event)
if(1 < control_changes.size())
{
warning() << "Contents of more than one control changed.\n";
- typedef std::vector<std::string>::const_iterator svci;
- for(svci i = control_changes.begin(); i != control_changes.end(); ++i)
+ for(auto const& i : control_changes)
{
- warning() << *i;
+ warning() << i;
}
warning() << LMI_FLUSH;
}
diff --git a/mvc_model.cpp b/mvc_model.cpp
index 41ed622..9bd23d8 100644
--- a/mvc_model.cpp
+++ b/mvc_model.cpp
@@ -171,11 +171,10 @@ void MvcModel::Harmonize()
void MvcModel::Transmogrify()
{
- typedef NamesType::const_iterator ntci;
- for(ntci i = Names().begin(); i != Names().end(); ++i)
+ for(auto const& i : Names())
{
- DoEnforceCircumscription(*i);
- DoEnforceProscription (*i);
+ DoEnforceCircumscription(i);
+ DoEnforceProscription (i);
}
DoTransmogrify();
}
diff --git a/policy_document.cpp b/policy_document.cpp
index 5dd7012..e1c2b0e 100644
--- a/policy_document.cpp
+++ b/policy_document.cpp
@@ -96,14 +96,9 @@ void PolicyDocument::ReadDocument(std::string const&
filename)
if(!GetViews().empty())
{
PolicyView& view = PredominantView();
- for
- (values_type::iterator it = values_.begin()
- ,end = values_.end()
- ;it != end
- ;++it
- )
+ for(auto const& i : values_)
{
- view.controls()[it->first]->SetValue(*it->second);
+ view.controls()[i.first]->SetValue(*i.second);
}
}
}
@@ -113,14 +108,9 @@ void PolicyDocument::WriteDocument(std::string const&
filename)
if(!GetViews().empty())
{
PolicyView& view = PredominantView();
- for
- (values_type::iterator it = values_.begin()
- ,end = values_.end()
- ;it != end
- ;++it
- )
+ for(auto const& i : values_)
{
- *it->second = view.controls()[it->first]->GetValue();
+ *i.second = view.controls()[i.first]->GetValue();
}
}
save(product_data_, filename);
diff --git a/policy_view.cpp b/policy_view.cpp
index 8615741..8424ceb 100644
--- a/policy_view.cpp
+++ b/policy_view.cpp
@@ -54,17 +54,11 @@ wxWindow* PolicyView::CreateChildWindow()
fatal_error() << "Unable to load xml resource." << LMI_FLUSH;
}
- typedef PolicyDocument::values_type::const_iterator value_const_iterator;
- for
- (value_const_iterator cit = document().values().begin()
- ,end = document().values().end()
- ;cit != end
- ;++cit
- )
+ for(auto const& i : document().values())
{
wxTextCtrl* text_ctrl = dynamic_cast<wxTextCtrl*>
(wxWindow::FindWindowById
- (wxXmlResource::GetXRCID(cit->first.c_str())
+ (wxXmlResource::GetXRCID(i.first.c_str())
,frame
)
);
@@ -72,12 +66,12 @@ wxWindow* PolicyView::CreateChildWindow()
{
fatal_error()
<< "Required text control '"
- << cit->first
+ << i.first
<< "' not found."
<< LMI_FLUSH
;
}
- controls_[cit->first] = text_ctrl;
+ controls_[i.first] = text_ctrl;
}
return main_panel;
@@ -100,14 +94,9 @@ PolicyDocument& PolicyView::document() const
bool PolicyView::IsModified() const
{
- for
- (controls_type::const_iterator it = controls().begin()
- ,end = controls().end()
- ;it != end
- ;++it
- )
+ for(auto const& i : controls())
{
- if(it->second->IsModified())
+ if(i.second->IsModified())
{
return true;
}
@@ -117,13 +106,8 @@ bool PolicyView::IsModified() const
void PolicyView::DiscardEdits()
{
- for
- (controls_type::iterator it = controls().begin()
- ,end = controls().end()
- ;it != end
- ;++it
- )
+ for(auto const& i : controls())
{
- it->second->DiscardEdits();
+ i.second->DiscardEdits();
}
}
diff --git a/preferences_model.cpp b/preferences_model.cpp
index 4a540bb..72cc6fd 100644
--- a/preferences_model.cpp
+++ b/preferences_model.cpp
@@ -190,21 +190,20 @@ void PreferencesModel::DoHarmonize()
weird_report_columns.push_back(mce_current_0_cash_surrender_value
);
weird_report_columns.push_back(mce_guaranteed_0_cash_surrender_value
);
- typedef std::vector<mcenum_report_column>::const_iterator vrci;
- for(vrci i = weird_report_columns.begin(); i !=
weird_report_columns.end(); ++i)
+ for(auto const& i : weird_report_columns)
{
- CalculationSummaryColumn00.allow(*i, false);
- CalculationSummaryColumn01.allow(*i, false);
- CalculationSummaryColumn02.allow(*i, false);
- CalculationSummaryColumn03.allow(*i, false);
- CalculationSummaryColumn04.allow(*i, false);
- CalculationSummaryColumn05.allow(*i, false);
- CalculationSummaryColumn06.allow(*i, false);
- CalculationSummaryColumn07.allow(*i, false);
- CalculationSummaryColumn08.allow(*i, false);
- CalculationSummaryColumn09.allow(*i, false);
- CalculationSummaryColumn10.allow(*i, false);
- CalculationSummaryColumn11.allow(*i, false);
+ CalculationSummaryColumn00.allow(i, false);
+ CalculationSummaryColumn01.allow(i, false);
+ CalculationSummaryColumn02.allow(i, false);
+ CalculationSummaryColumn03.allow(i, false);
+ CalculationSummaryColumn04.allow(i, false);
+ CalculationSummaryColumn05.allow(i, false);
+ CalculationSummaryColumn06.allow(i, false);
+ CalculationSummaryColumn07.allow(i, false);
+ CalculationSummaryColumn08.allow(i, false);
+ CalculationSummaryColumn09.allow(i, false);
+ CalculationSummaryColumn10.allow(i, false);
+ CalculationSummaryColumn11.allow(i, false);
}
}
diff --git a/product_data.cpp b/product_data.cpp
index a3cbcf9..c547ce5 100644
--- a/product_data.cpp
+++ b/product_data.cpp
@@ -531,10 +531,9 @@ void product_data::write_policy_files()
// 'sample2' product
- typedef std::vector<std::string>::const_iterator svci;
- for(svci i = z.member_names().begin(); i != z.member_names().end(); ++i)
+ for(auto const& i : z.member_names())
{
- z[*i] = '{' + *i + '}';
+ z[i] = '{' + i + '}';
}
// Names of lmi product files.
diff --git a/regex_test.cpp b/regex_test.cpp
index 06c22f1..4b7b2c9 100644
--- a/regex_test.cpp
+++ b/regex_test.cpp
@@ -163,10 +163,9 @@ bool contains_regex0(std::string const& regex)
bool contains_regex1(std::string const& regex)
{
boost::regex const r(regex, boost::regex::sed);
- typedef std::vector<std::string>::const_iterator vsi;
- for(vsi i = lines.begin(); i != lines.end(); ++i)
+ for(auto const& i : lines)
{
- if(boost::regex_search(*i, r))
+ if(boost::regex_search(i, r))
{
return true;
}
@@ -223,12 +222,11 @@ char never[] = "lord";
void test_psalm_37()
{
lines = vectorize(original);
- typedef std::vector<std::string>::iterator vsi;
- for(vsi i = lines.begin(); i != lines.end(); ++i)
+ for(auto const& i : lines)
{
for(int j = 0; j < 10; ++j)
{
- text += *i + '\n';
+ text += i + '\n';
}
}
lines = vectorize(text);
diff --git a/rounding_document.cpp b/rounding_document.cpp
index 47c8588..51b19ae 100644
--- a/rounding_document.cpp
+++ b/rounding_document.cpp
@@ -76,10 +76,9 @@ void RoundingDocument::ReadDocument(std::string const&
filename)
if(!GetViews().empty())
{
RoundingView& view = PredominantView();
- typedef values_type::const_iterator vtci;
- for(vtci i = values_.begin(); i != values_.end(); ++i)
+ for(auto const& i : values_)
{
- view.controls()[i->first]->SetValue(*i->second);
+ view.controls()[i.first]->SetValue(*i.second);
}
}
}
@@ -89,10 +88,9 @@ void RoundingDocument::WriteDocument(std::string const&
filename)
if(!GetViews().empty())
{
RoundingView& view = PredominantView();
- typedef values_type::const_iterator vtci;
- for(vtci i = values_.begin(); i != values_.end(); ++i)
+ for(auto const& i : values_)
{
- *i->second = view.controls()[i->first]->GetValue();
+ *i.second = view.controls()[i.first]->GetValue();
}
}
save(rounding_rules_, filename);
diff --git a/rounding_view.cpp b/rounding_view.cpp
index 6126b21..9fb5bd7 100644
--- a/rounding_view.cpp
+++ b/rounding_view.cpp
@@ -54,17 +54,11 @@ wxWindow* RoundingView::CreateChildWindow()
fatal_error() << "Unable to load xml resource." << LMI_FLUSH;
}
- typedef RoundingDocument::values_type::const_iterator value_const_iterator;
- for
- (value_const_iterator cit = document().values().begin()
- ,end = document().values().end()
- ;cit != end
- ;++cit
- )
+ for(auto const& i : document().values())
{
RoundingButtons* control = dynamic_cast<RoundingButtons*>
(wxWindow::FindWindowById
- (wxXmlResource::GetXRCID(cit->first.c_str())
+ (wxXmlResource::GetXRCID(i.first.c_str())
,frame
)
);
@@ -72,12 +66,12 @@ wxWindow* RoundingView::CreateChildWindow()
{
fatal_error()
<< "Required text control '"
- << cit->first
+ << i.first
<< "' not found."
<< LMI_FLUSH
;
}
- controls_[cit->first] = control;
+ controls_[i.first] = control;
}
return main_panel;
}
@@ -99,14 +93,9 @@ RoundingDocument& RoundingView::document() const
bool RoundingView::IsModified() const
{
- for
- (controls_type::const_iterator it = controls().begin()
- ,end = controls().end()
- ;it != end
- ;++it
- )
+ for(auto const& i : controls())
{
- if(it->second->IsModified())
+ if(i.second->IsModified())
{
return true;
}
@@ -116,14 +105,9 @@ bool RoundingView::IsModified() const
void RoundingView::DiscardEdits()
{
- for
- (controls_type::const_iterator it = controls().begin()
- ,end = controls().end()
- ;it != end
- ;++it
- )
+ for(auto const& i : controls())
{
- it->second->DiscardEdits();
+ i.second->DiscardEdits();
}
}
diff --git a/skeleton.cpp b/skeleton.cpp
index 0e2a13b..5a9c1a3 100644
--- a/skeleton.cpp
+++ b/skeleton.cpp
@@ -100,7 +100,7 @@
#include <wx/utils.h> // wxMilliSleep(), wxSafeYield()
#include <wx/xrc/xmlres.h>
-#include <iterator>
+#include <iterator> // std::insert_iterator
#include <sstream>
#include <stdexcept>
#include <string>
@@ -821,10 +821,9 @@ void Skeleton::UponMenuOpen(wxMenuEvent& event)
if(child_frame)
{
bool has_multiple_mdi_children = false;
- wxWindowList const& wl = frame_->GetChildren();
- for(wxWindowList::const_iterator i = wl.begin(); i != wl.end(); ++i)
+ for(auto const& i : frame_->GetChildren())
{
- wxMDIChildFrame const*const child =
dynamic_cast<wxMDIChildFrame*>(*i);
+ wxMDIChildFrame const*const child =
dynamic_cast<wxMDIChildFrame*>(i);
if(child && child != child_frame)
{
has_multiple_mdi_children = true;
@@ -860,15 +859,14 @@ namespace
new_text.reserve(original_text.size());
std::insert_iterator<std::string> j(new_text, new_text.begin());
- typedef std::string::const_iterator sci;
- for(sci i = original_text.begin(); i != original_text.end(); ++i)
+ for(auto const& i : original_text)
{
- switch(*i)
+ switch(i)
{
case '\n': {*j++ = ';';} break;
case '\r': { } break;
case '\t': {*j++ = ';';} break;
- default : {*j++ = *i;}
+ default : {*j++ = i;}
}
}
@@ -1368,14 +1366,13 @@ void
Skeleton::OpenCommandLineFiles(std::vector<std::string> const& files)
{
LMI_ASSERT(doc_manager_);
- typedef std::vector<std::string>::const_iterator vsci;
- for(vsci i = files.begin(); i != files.end(); ++i)
+ for(auto const& i : files)
{
- if(!doc_manager_->CreateDocument(*i, wxDOC_SILENT))
+ if(!doc_manager_->CreateDocument(i, wxDOC_SILENT))
{
warning()
<< "Document '"
- << *i
+ << i
<< "' specified on command line couldn't be opened."
<< LMI_FLUSH
;
@@ -1386,10 +1383,9 @@ void
Skeleton::OpenCommandLineFiles(std::vector<std::string> const& files)
void Skeleton::UpdateViews()
{
wxBusyCursor wait;
- wxWindowList const& wl = frame_->GetChildren();
- for(wxWindowList::const_iterator i = wl.begin(); i != wl.end(); ++i)
+ for(auto const& i : frame_->GetChildren())
{
- wxDocMDIChildFrame const* c = dynamic_cast<wxDocMDIChildFrame*>(*i);
+ wxDocMDIChildFrame const* c = dynamic_cast<wxDocMDIChildFrame*>(i);
if(c)
{
IllustrationView* v =
dynamic_cast<IllustrationView*>(c->GetView());
diff --git a/tier_document.cpp b/tier_document.cpp
index 1ada783..6a27482 100644
--- a/tier_document.cpp
+++ b/tier_document.cpp
@@ -51,11 +51,9 @@ void TierDocument::initialize_charges()
(std::vector<double>(1, infinity<double>()) // limits
,std::vector<double>(1, 0.0) // values
);
- std::vector<std::string> const& v = charges_.member_names();
- typedef std::vector<std::string>::const_iterator svci;
- for(svci i = v.begin(); i != v.end(); ++i)
+ for(auto const& i : charges_.member_names())
{
- charges_.datum(*i) = dummy_entity;
+ charges_.datum(i) = dummy_entity;
}
}
diff --git a/tier_view.cpp b/tier_view.cpp
index 3f7cdf3..ce841c3 100644
--- a/tier_view.cpp
+++ b/tier_view.cpp
@@ -122,14 +122,12 @@ MultiDimGrid* TierView::CreateGridCtrl(wxWindow* parent)
void TierView::SetupControls()
{
- std::vector<tier_entity_info> const& entities = get_tier_entity_infos();
std::map<e_stratified, wxTreeItemId> index_to_id;
wxTreeCtrl& tree_ctrl = tree();
- for(std::size_t i = 0; i < entities.size(); ++i)
+ for(auto const& entity : get_tier_entity_infos())
{
- tier_entity_info const& entity = entities[i];
if(entity.index == entity.parent_index)
{
wxTreeItemId id = tree_ctrl.AddRoot("");
diff --git a/view_ex.tpp b/view_ex.tpp
index 2942765..aaf6c92 100644
--- a/view_ex.tpp
+++ b/view_ex.tpp
@@ -63,10 +63,8 @@ template<typename ViewType>
ViewType& PredominantView(wxDocument const& document)
{
ViewType* view = nullptr;
- wxList const& views = document.GetViews();
- for(wxList::const_iterator i = views.begin(); i != views.end(); ++i)
+ for(auto const& p : document.GetViews())
{
- wxObject* p = *i;
LMI_ASSERT(nullptr != p);
if(p->IsKindOf(CLASSINFO(ViewType)))
{
diff --git a/wx_test_about_version.cpp b/wx_test_about_version.cpp
index 1e0be0a..58c74d0 100644
--- a/wx_test_about_version.cpp
+++ b/wx_test_about_version.cpp
@@ -83,25 +83,23 @@ int year_from_string(wxString const& s)
int extract_last_copyright_year(wxString const& html)
{
// Find the line starting with "Copyright".
- wxArrayString const lines = wxSplit(html ,'\n' ,'\0');
-
- wxString line;
- for(wxArrayString::const_iterator i = lines.begin(); i != lines.end(); ++i)
+ wxString copyright_line;
+ for(auto const& line : wxSplit(html ,'\n' ,'\0'))
{
- if(i->StartsWith("Copyright"))
+ if(line.StartsWith("Copyright"))
{
LMI_ASSERT_WITH_MSG
- (line.empty()
+ (copyright_line.empty()
,"Unexpectedly found more than one copyright line in the "
"license notices text"
);
- line = *i;
+ copyright_line = line;
}
}
LMI_ASSERT_WITH_MSG
- (!line.empty()
+ (!copyright_line.empty()
,"Copyright line not found in the license notices text"
);
@@ -116,15 +114,17 @@ int extract_last_copyright_year(wxString const& html)
// and notably not with MinGW 3.4. As we are only interested in matching
// ASCII characters such as digits, using UTF-8 is safe even though
// boost::regex has no real support for it.
- std::string const line_utf8(line.utf8_str());
+ std::string const copyright_line_utf8(copyright_line.utf8_str());
boost::smatch m;
LMI_ASSERT_WITH_MSG
(boost::regex_search
- (line_utf8
+ (copyright_line_utf8
,m
,boost::regex("(?:\\d{4}, )+(\\d{4})")
)
- ,"Copyright line \"" + line + "\" doesn't contain copyright years"
+ , "Copyright line \""
+ + copyright_line
+ + "\" doesn't contain copyright years"
);
return year_from_string(wxString(m[1]));
@@ -137,10 +137,9 @@ int extract_last_copyright_year(wxString const& html)
wxHtmlWindow* find_html_window(wxWindow* parent, std::string const&
dialog_name)
{
wxHtmlWindow* html_win = nullptr;
- wxWindowList const& wl = parent->GetChildren();
- for(wxWindowList::const_iterator i = wl.begin(); i != wl.end(); ++i)
+ for(auto const& w : parent->GetChildren())
{
- wxHtmlWindow* const maybe_html_win = dynamic_cast<wxHtmlWindow*>(*i);
+ wxHtmlWindow* const maybe_html_win = dynamic_cast<wxHtmlWindow*>(w);
if(maybe_html_win)
{
LMI_ASSERT_WITH_MSG
diff --git a/wx_test_input_sequences.cpp b/wx_test_input_sequences.cpp
index 4bbbd4f..05211c9 100644
--- a/wx_test_input_sequences.cpp
+++ b/wx_test_input_sequences.cpp
@@ -161,10 +161,10 @@ LMI_WX_TEST_CASE(input_sequences)
};
wxUIActionSimulator ui;
- for(std::size_t n = 0; n < sizeof test_cases / sizeof(test_cases[0]); n++)
+ for(auto const& test : test_cases)
{
ui.Char('e', wxMOD_CONTROL); // "Illustration|Edit Cell"
- wxTEST_DIALOG(wxYield(), test_sequence_dialog(test_cases[n]));
+ wxTEST_DIALOG(wxYield(), test_sequence_dialog(test));
}
ill.close_discard_changes();
diff --git a/wx_test_input_validation.cpp b/wx_test_input_validation.cpp
index cb078de..aae4af3 100644
--- a/wx_test_input_validation.cpp
+++ b/wx_test_input_validation.cpp
@@ -133,10 +133,8 @@ LMI_WX_TEST_CASE(input_validation)
char const* const value_;
};
- for(std::size_t n = 0; n < sizeof test_cases / sizeof(test_cases[0]); n++)
+ for(auto const& td : test_cases)
{
- coi_multiplier_test_data const& td = test_cases[n];
-
// This flag is used to assert that all expected exceptions were
// generated at the end of the loop. The reason for using it instead of
// just asserting directly inside the "try" statement is that failing
diff --git a/wx_test_paste_census.cpp b/wx_test_paste_census.cpp
index 90e5f0b..86db9f6 100644
--- a/wx_test_paste_census.cpp
+++ b/wx_test_paste_census.cpp
@@ -93,8 +93,7 @@ std::string build_not_found_message(std::set<std::string>
const& remaining)
bool const only_one = remaining.size() == 1;
message << (only_one ? "column" : "columns");
- typedef std::set<std::string>::const_iterator ssci;
- for(ssci i = remaining.begin(); i != remaining.end(); ++i)
+ for(auto i = remaining.begin(); i != remaining.end(); ++i)
{
if(i != remaining.begin())
{
diff --git a/wx_utility.cpp b/wx_utility.cpp
index a1c99cf..23cd3c8 100644
--- a/wx_utility.cpp
+++ b/wx_utility.cpp
@@ -231,10 +231,8 @@ void EnumerateLineage
,std::vector<wxWindow*>& v
)
{
- wxWindowList const& wl = w->GetChildren();
- for(wxWindowList::const_iterator i = wl.begin(); i != wl.end(); ++i)
+ for(auto const& c : w->GetChildren())
{
- wxWindow* c = *i;
LMI_ASSERT(nullptr != c);
v.push_back(c);
EnumerateLineage(c, v);