diff options
author | 2016-08-04 21:57:23 -0700 | |
---|---|---|
committer | 2016-08-04 22:11:01 -0700 | |
commit | f3cd2455110fad09158275287cbdaa67cc3e15c3 (patch) | |
tree | b1922ea17b1401f0e86c6e3cdaf3a278dade4557 | |
parent | e9ccc3a086f57507712a44ef2fadc34affa13af9 (diff) | |
download | paludis-f3cd2455110fad09158275287cbdaa67cc3e15c3.tar.gz paludis-f3cd2455110fad09158275287cbdaa67cc3e15c3.tar.xz |
modernize: convert to range based for-loops
Automated conversion to range based for loops. NFC
59 files changed, 415 insertions, 532 deletions
diff --git a/doc/api/cplusplus/examples/example_version_operator.cc b/doc/api/cplusplus/examples/example_version_operator.cc index 9369e8cec..a6e86fc15 100644 --- a/doc/api/cplusplus/examples/example_version_operator.cc +++ b/doc/api/cplusplus/examples/example_version_operator.cc @@ -68,10 +68,9 @@ int main(int argc, char * argv[]) for (std::set<VersionSpec>::const_iterator v1(versions.begin()), v1_end(versions.end()) ; v1 != v1_end ; ++v1) { - for (std::set<VersionSpec>::const_iterator v2(versions.begin()), v2_end(versions.end()) ; - v2 != v2_end ; ++v2) + for (const auto & version : versions) { - cout << " " << left << setw(8) << *v1 << " | " << left << setw(8) << *v2; + cout << " " << left << setw(8) << *v1 << " | " << left << setw(8) << version; /* Apply all of our operators, and show the results */ for (std::list<VersionOperator>::const_iterator o(operators.begin()), o_end(operators.end()) ; @@ -79,7 +78,7 @@ int main(int argc, char * argv[]) { /* VersionOperator::as_version_spec_comparator returns a * binary boolean functor. */ - cout << " | " << left << setw(8) << boolalpha << (o->as_version_spec_comparator()(*v1, *v2)); + cout << " | " << left << setw(8) << boolalpha << (o->as_version_spec_comparator()(*v1, version)); } cout << endl; diff --git a/doc/api/cplusplus/examples/example_version_spec.cc b/doc/api/cplusplus/examples/example_version_spec.cc index a6048d794..59947577f 100644 --- a/doc/api/cplusplus/examples/example_version_spec.cc +++ b/doc/api/cplusplus/examples/example_version_spec.cc @@ -50,21 +50,20 @@ int main(int argc, char * argv[]) versions.insert(VersionSpec("9999", user_version_spec_options())); /* For each version... */ - for (std::set<VersionSpec>::const_iterator v(versions.begin()), v_end(versions.end()) ; - v != v_end ; ++v) + for (const auto & version : versions) { /* Versions are stringifiable */ - cout << *v << ":" << endl; + cout << version << ":" << endl; /* Show the output of various members. Not all of these are of much * direct use. */ - cout << " " << left << setw(24) << "Hash value:" << " " << "0x" << hex << v->hash() << endl; - cout << " " << left << setw(24) << "Remove revision:" << " " << v->remove_revision() << endl; - cout << " " << left << setw(24) << "Revision only:" << " " << v->revision_only() << endl; - cout << " " << left << setw(24) << "Bump:" << " " << v->bump() << endl; - cout << " " << left << setw(24) << "Is scm?" << " " << boolalpha << v->is_scm() << endl; - cout << " " << left << setw(24) << "Has -try?" << " " << boolalpha << v->has_try_part() << endl; - cout << " " << left << setw(24) << "Has -scm?" << " " << boolalpha << v->has_scm_part() << endl; + cout << " " << left << setw(24) << "Hash value:" << " " << "0x" << hex << version.hash() << endl; + cout << " " << left << setw(24) << "Remove revision:" << " " << version.remove_revision() << endl; + cout << " " << left << setw(24) << "Revision only:" << " " << version.revision_only() << endl; + cout << " " << left << setw(24) << "Bump:" << " " << version.bump() << endl; + cout << " " << left << setw(24) << "Is scm?" << " " << boolalpha << version.is_scm() << endl; + cout << " " << left << setw(24) << "Has -try?" << " " << boolalpha << version.has_try_part() << endl; + cout << " " << left << setw(24) << "Has -scm?" << " " << boolalpha << version.has_scm_part() << endl; cout << endl; } } diff --git a/paludis/args/escape.cc b/paludis/args/escape.cc index 47b41b6de..eb4da18d8 100644 --- a/paludis/args/escape.cc +++ b/paludis/args/escape.cc @@ -27,17 +27,16 @@ const std::string paludis::args::escape(const std::string & s) { std::stringstream result; - for (std::string::const_iterator c(s.begin()), c_end(s.end()) ; - c != c_end ; ++c) + for (char c : s) { - if ((*c >= 'a' && *c <= 'z') || - (*c >= 'A' && *c <= 'Z') || - (*c >= '0' && *c <= '9') || - *c == '-' || - *c == '_') - result << *c; + if ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-' || + c == '_') + result << c; else - result << '\\' << *c; + result << '\\' << c; } return result.str(); diff --git a/paludis/args/man.cc b/paludis/args/man.cc index ff1a4d451..c79632da7 100644 --- a/paludis/args/man.cc +++ b/paludis/args/man.cc @@ -194,7 +194,7 @@ namespace void escape_asciidoc(std::ostream & stream, const std::string & s) { char previous('\0'); - for (auto t(s.begin()), t_end(s.end()) ; t != t_end ; ++t) + for (char t : s) { switch (previous) { @@ -203,13 +203,13 @@ namespace case '\n': case '\t': case '\'': - if ('*' == *t) + if ('*' == t) stream << '\\'; break; // Escape '*/*' -> '\*/*' } - stream << *t; - previous = *t; + stream << t; + previous = t; } } } diff --git a/paludis/changed_choices.cc b/paludis/changed_choices.cc index 31421484f..53c01292b 100644 --- a/paludis/changed_choices.cc +++ b/paludis/changed_choices.cc @@ -61,14 +61,13 @@ ChangedChoices::empty() const void ChangedChoices::add_additional_requirements_to(PartiallyMadePackageDepSpec & spec) const { - for (auto o(_imp->overrides.begin()), o_end(_imp->overrides.end()) ; - o != o_end ; ++o) + for (const auto & override : _imp->overrides) { - if (o->second) - spec.additional_requirement(parse_elike_use_requirement("" + stringify(o->first) + "(-)", + if (override.second) + spec.additional_requirement(parse_elike_use_requirement("" + stringify(override.first) + "(-)", { euro_allow_default_values }, nullptr)); else - spec.additional_requirement(parse_elike_use_requirement("-" + stringify(o->first) + "(-)", + spec.additional_requirement(parse_elike_use_requirement("-" + stringify(override.first) + "(-)", { euro_allow_default_values }, nullptr)); } } @@ -91,12 +90,11 @@ ChangedChoices::serialise(Serialiser & s) const ss.member(SerialiserFlags<>(), "count", stringify(_imp->overrides.size())); int n(0); - for (auto o(_imp->overrides.begin()), o_end(_imp->overrides.end()) ; - o != o_end ; ++o) + for (const auto & override : _imp->overrides) { ++n; - ss.member(SerialiserFlags<>(), stringify(n) + "a" , stringify(o->first)); - ss.member(SerialiserFlags<>(), stringify(n) + "b" , stringify(o->second)); + ss.member(SerialiserFlags<>(), stringify(n) + "a" , stringify(override.first)); + ss.member(SerialiserFlags<>(), stringify(n) + "b" , stringify(override.second)); } } diff --git a/paludis/elike_use_requirement.cc b/paludis/elike_use_requirement.cc index 3699f7a84..31051c535 100644 --- a/paludis/elike_use_requirement.cc +++ b/paludis/elike_use_requirement.cc @@ -555,10 +555,9 @@ namespace using namespace std::placeholders; std::pair<bool, std::string> result(true, ""); - for (Reqs::const_iterator r(_reqs.begin()), r_end(_reqs.end()) ; - r != r_end ; ++r) + for (const auto & _req : _reqs) { - std::pair<bool, std::string> r_result((*r)->requirement_met(env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target)); + std::pair<bool, std::string> r_result(_req->requirement_met(env, maybe_changes_to_owner, id, from_id, maybe_changes_to_target)); if (! r_result.first) { if (! result.first) @@ -596,10 +595,9 @@ namespace ChangedChoices & changed_choices) const { Tribool result(indeterminate); - for (auto r(_reqs.begin()), r_end(_reqs.end()) ; - r != r_end ; ++r) + for (const auto & _req : _reqs) { - auto b((*r)->accumulate_changes_to_make_met(env, maybe_changes_to_owner, id, from_id, changed_choices)); + auto b(_req->accumulate_changes_to_make_met(env, maybe_changes_to_owner, id, from_id, changed_choices)); if (b.is_false()) return false; else if (b.is_true()) diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc index fceaa932f..f4d535784 100644 --- a/paludis/environment_implementation.cc +++ b/paludis/environment_implementation.cc @@ -222,10 +222,8 @@ EnvironmentImplementation::remove_notifier_callback(const NotifierCallbackID i) void EnvironmentImplementation::trigger_notifier_callback(const NotifierCallbackEvent & e) const { - for (std::map<unsigned, NotifierCallbackFunction>::const_iterator i(_imp->notifier_callbacks.begin()), - i_end(_imp->notifier_callbacks.end()) ; - i != i_end ; ++i) - (i->second)(e); + for (const auto & notifier_callback : _imp->notifier_callbacks) + (notifier_callback.second)(e); } void @@ -369,12 +367,10 @@ EnvironmentImplementation::add_repository(int importance, const std::shared_ptr< throw DuplicateRepositoryError(stringify(repository->name())); std::list<std::shared_ptr<Repository> >::iterator q(_imp->repositories.end()); - for (std::multimap<int, std::list<std::shared_ptr<Repository> >::iterator>::iterator - p(_imp->repository_importances.begin()), p_end(_imp->repository_importances.end()) ; - p != p_end ; ++p) - if (p->first > importance) + for (auto & repository_importance : _imp->repository_importances) + if (repository_importance.first > importance) { - q = p->second; + q = repository_importance.second; break; } diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc index 2b8c786f6..defcb97f6 100644 --- a/paludis/environments/paludis/keywords_conf.cc +++ b/paludis/environments/paludis/keywords_conf.cc @@ -145,22 +145,20 @@ KeywordsConf::query(const std::shared_ptr<const KeywordNameSet> & k, const std:: SpecificMap::const_iterator i(_imp->qualified.find(e->name())); if (i != _imp->qualified.end()) { - for (PDSToKeywordsList::const_iterator j(i->second.begin()), j_end(i->second.end()) ; - j != j_end ; ++j) + for (const auto & j : i->second) { - if (! match_package(*_imp->env, *j->first, e, nullptr, { })) + if (! match_package(*_imp->env, *j.first, e, nullptr, { })) continue; - for (KeywordsList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j.second) { - if (*l == star_keyword) + if (l == star_keyword) return true; - else if (*l == minus_star_keyword) + else if (l == minus_star_keyword) break_when_done = true; - else if (k->end() != k->find(*l)) + else if (k->end() != k->find(l)) return true; } } @@ -217,13 +215,12 @@ KeywordsConf::query(const std::shared_ptr<const KeywordNameSet> & k, const std:: if (! match_package(*_imp->env, *j->first, e, nullptr, { })) continue; - for (KeywordsList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j->second) { - if (k->end() != k->find(*l)) + if (k->end() != k->find(l)) return true; - if (*l == star_keyword) + if (l == star_keyword) return true; } } diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc index 7da32f1d2..0d6bfba97 100644 --- a/paludis/environments/paludis/licenses_conf.cc +++ b/paludis/environments/paludis/licenses_conf.cc @@ -139,20 +139,19 @@ namespace void expand(const Environment * const env, LicensesList & list) { LicensesList extras; - for (auto i(list.begin()), i_end(list.end()) ; - i != i_end ; ++i) + for (auto & i : list) { - std::string s(*i); + std::string s(i); if (0 == s.compare(0, 1, "-", 0, 1)) { - auto l(env->expand_licence(i->substr(1))); + auto l(env->expand_licence(i.substr(1))); for (auto v(l->begin()), v_end(l->end()) ; v != v_end ; ++v) extras.push_back("-" + *v); } else { - auto l(env->expand_licence(*i)); + auto l(env->expand_licence(i)); for (auto v(l->begin()), v_end(l->end()) ; v != v_end ; ++v) extras.push_back(*v); @@ -175,9 +174,8 @@ LicensesConf::query(const std::string & t, const std::shared_ptr<const PackageID for (auto q(_imp->qualified.begin()), q_end(_imp->qualified.end()) ; q != q_end ; ++q) { - for (auto p(q->second.begin()), p_end(q->second.end()) ; - p != p_end ; ++p) - expand(_imp->env, p->second); + for (auto & p : q->second) + expand(_imp->env, p.second); } for (auto p(_imp->unqualified.begin()), p_end(_imp->unqualified.end()) ; @@ -196,22 +194,20 @@ LicensesConf::query(const std::string & t, const std::shared_ptr<const PackageID SpecificMap::const_iterator i(_imp->qualified.find(e->name())); if (i != _imp->qualified.end()) { - for (PDSToLicensesList::const_iterator j(i->second.begin()), j_end(i->second.end()) ; - j != j_end ; ++j) + for (const auto & j : i->second) { - if (! match_package(*_imp->env, *j->first, e, nullptr, { })) + if (! match_package(*_imp->env, *j.first, e, nullptr, { })) continue; - for (LicensesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j.second) { - if (*l == t) + if (l == t) return true; - if (*l == "*") + if (l == "*") return true; - if (*l == "-*") + if (l == "-*") break_when_done = true; } } @@ -267,13 +263,12 @@ LicensesConf::query(const std::string & t, const std::shared_ptr<const PackageID if (! match_package(*_imp->env, *j->first, e, nullptr, { })) continue; - for (LicensesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j->second) { - if (*l == t) + if (l == t) return true; - if (*l == "*") + if (l == "*") return true; } } diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc index 4bc180843..033ce77a2 100644 --- a/paludis/environments/paludis/paludis_environment.cc +++ b/paludis/environments/paludis/paludis_environment.cc @@ -507,15 +507,14 @@ PaludisEnvironment::populate_sets() const sets_dirs.push_back(FSPath(LIBDIR) / "paludis" / "sets"); } - for (auto sets_dir(sets_dirs.begin()), sets_dir_end(sets_dirs.end()) ; - sets_dir != sets_dir_end ; ++ sets_dir) + for (auto & sets_dir : sets_dirs) { - Context context("When looking in sets directory '" + stringify(*sets_dir) + "':"); + Context context("When looking in sets directory '" + stringify(sets_dir) + "':"); - if (! sets_dir->stat().exists()) + if (! sets_dir.stat().exists()) continue; - for (FSIterator d(*sets_dir, { fsio_inode_sort }), d_end ; d != d_end ; ++d) + for (FSIterator d(sets_dir, { fsio_inode_sort }), d_end ; d != d_end ; ++d) { if (is_file_with_extension(*d, ".bash", { })) { diff --git a/paludis/environments/paludis/suggestions_conf.cc b/paludis/environments/paludis/suggestions_conf.cc index bedf4046a..89529da6b 100644 --- a/paludis/environments/paludis/suggestions_conf.cc +++ b/paludis/environments/paludis/suggestions_conf.cc @@ -190,30 +190,28 @@ SuggestionsConf::interest_in_suggestion( SpecificMap::const_iterator i(_imp->qualified.find(from_id->name())); if (i != _imp->qualified.end()) { - for (PDSToValuesList::const_iterator j(i->second.begin()), j_end(i->second.end()) ; - j != j_end ; ++j) + for (const auto & j : i->second) { - if (! match_package(*_imp->env, *j->first, from_id, nullptr, { })) + if (! match_package(*_imp->env, *j.first, from_id, nullptr, { })) continue; - for (ValuesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j.second) { - if (! l->group_requirement.empty()) + if (! l.group_requirement.empty()) { - if (spec_group == l->group_requirement) - return l->negated ? false : true; + if (spec_group == l.group_requirement) + return l.negated ? false : true; } else { - if (! l->pkg_requirement.empty()) - if (stringify(spec.package_ptr()->package()) != l->pkg_requirement) + if (! l.pkg_requirement.empty()) + if (stringify(spec.package_ptr()->package()) != l.pkg_requirement) continue; - if (! l->cat_requirement.empty()) - if (stringify(spec.package_ptr()->category()) != l->cat_requirement) + if (! l.cat_requirement.empty()) + if (stringify(spec.package_ptr()->category()) != l.cat_requirement) continue; - return l->negated ? false : true; + return l.negated ? false : true; } } } @@ -271,24 +269,23 @@ SuggestionsConf::interest_in_suggestion( if (! match_package(*_imp->env, *j->first, from_id, nullptr, { })) continue; - for (ValuesList::const_iterator l(j->second.begin()), l_end(j->second.end()) ; - l != l_end ; ++l) + for (const auto & l : j->second) { - if (! l->group_requirement.empty()) + if (! l.group_requirement.empty()) { - if (spec_group == l->group_requirement) - return l->negated ? false : true; + if (spec_group == l.group_requirement) + return l.negated ? false : true; } else { - if (! l->pkg_requirement.empty()) - if (stringify(spec.package_ptr()->package()) != l->pkg_requirement) + if (! l.pkg_requirement.empty()) + if (stringify(spec.package_ptr()->package()) != l.pkg_requirement) continue; - if (! l->cat_requirement.empty()) - if (stringify(spec.package_ptr()->category()) != l->cat_requirement) + if (! l.cat_requirement.empty()) + if (stringify(spec.package_ptr()->category()) != l.cat_requirement) continue; - return l->negated ? false : true; + return l.negated ? false : true; } } } diff --git a/paludis/fs_merger.cc b/paludis/fs_merger.cc index 0fa032193..28132d229 100644 --- a/paludis/fs_merger.cc +++ b/paludis/fs_merger.cc @@ -156,14 +156,14 @@ FSMerger::prepare_install_under() for (FSPath d(_imp->params.root().realpath() / _imp->params.install_under()), d_end(_imp->params.root().realpath()) ; d != d_end ; d = d.dirname()) dd.push_front(d); - for (std::list<FSPath>::iterator d(dd.begin()), d_end(dd.end()) ; d != d_end ; ++d) - if (! d->stat().exists()) + for (auto & d : dd) + if (! d.stat().exists()) { - d->mkdir(0755, { }); - track_install_under_dir(*d, FSMergerStatusFlags()); + d.mkdir(0755, { }); + track_install_under_dir(d, FSMergerStatusFlags()); } else - track_install_under_dir(*d, FSMergerStatusFlags() + msi_used_existing); + track_install_under_dir(d, FSMergerStatusFlags() + msi_used_existing); } void diff --git a/paludis/hooker.cc b/paludis/hooker.cc index 9f1ec3851..1c339bff9 100644 --- a/paludis/hooker.cc +++ b/paludis/hooker.cc @@ -376,17 +376,16 @@ FancyHookFile::_add_dependency_class(const Hook & hook, DirectedGraph<std::strin std::set<std::string> deps_s; tokenise_whitespace(deps, std::inserter(deps_s, deps_s.end())); - for (std::set<std::string>::const_iterator d(deps_s.begin()), d_end(deps_s.end()) ; - d != d_end ; ++d) + for (const auto & deps_ : deps_s) { - if (g.has_node(*d)) - g.add_edge(strip_trailing_string(file_name().basename(), ".hook"), *d, 0); + if (g.has_node(deps_)) + g.add_edge(strip_trailing_string(file_name().basename(), ".hook"), deps_, 0); else if (depend) Log::get_instance()->message("hook.fancy.dependency_not_found", ll_warning, lc_context) - << "Hook dependency '" << *d << "' for '" << file_name() << "' not found"; + << "Hook dependency '" << deps_ << "' for '" << file_name() << "' not found"; else Log::get_instance()->message("hook.fancy.after_not_found", ll_debug, lc_context) - << "Hook after '" << *d << "' for '" << file_name() << "' not found"; + << "Hook after '" << deps_ << "' for '" << file_name() << "' not found"; } } else @@ -490,10 +489,9 @@ namespace paludis Context context("When loading auto hooks:"); - for (std::list<std::pair<FSPath, bool> >::const_iterator d(dirs.begin()), d_end(dirs.end()) ; - d != d_end ; ++d) + for (const auto & dir : dirs) { - FSPath d_a(d->first / "auto"); + FSPath d_a(dir.first / "auto"); if (! d_a.stat().is_directory()) continue; @@ -504,12 +502,12 @@ namespace paludis if (is_file_with_extension(*e, ".hook", { })) { - hook_file = std::make_shared<FancyHookFile>(*e, d->second, env); + hook_file = std::make_shared<FancyHookFile>(*e, dir.second, env); name = strip_trailing_string(e->basename(), ".hook"); } else if (is_file_with_extension(*e, so_suffix, { })) { - hook_file = std::make_shared<SoHookFile>(*e, d->second, env); + hook_file = std::make_shared<SoHookFile>(*e, dir.second, env); name = strip_trailing_string(e->basename(), so_suffix); } diff --git a/paludis/paludislike_options_conf.cc b/paludis/paludislike_options_conf.cc index 44291cc0c..68465aa63 100644 --- a/paludis/paludislike_options_conf.cc +++ b/paludis/paludislike_options_conf.cc @@ -362,15 +362,14 @@ namespace std::string & result_value) { - for (ValuesGroups::const_iterator i(values_groups.begin()), i_end(values_groups.end()) ; - i != i_end ; ++i) + for (const auto & values_group : values_groups) { - if (i->prefix() != prefix) + if (values_group.prefix() != prefix) continue; - seen_minus_star = seen_minus_star || i->minus_star(); + seen_minus_star = seen_minus_star || values_group.minus_star(); - std::pair<Values::const_iterator, Values::const_iterator> range(i->values().equal_range( + std::pair<Values::const_iterator, Values::const_iterator> range(values_group.values().equal_range( make_named_values<Value>( n::equals_value() = "", n::locked() = false, @@ -398,15 +397,13 @@ namespace const std::shared_ptr<Set<UnprefixedChoiceName> > & known) { - for (ValuesGroups::const_iterator i(values_groups.begin()), i_end(values_groups.end()) ; - i != i_end ; ++i) + for (const auto & values_group : values_groups) { - if (i->prefix() != prefix) + if (values_group.prefix() != prefix) continue; - for (Values::const_iterator v(i->values().begin()), v_end(i->values().end()) ; - v != v_end ; ++v) - known->insert(v->unprefixed_name()); + for (const auto & v : values_group.values()) + known->insert(v.unprefixed_name()); } } @@ -420,22 +417,20 @@ namespace std::pair<Tribool, bool> & result_state, std::string & result_value) { - for (SpecsWithValuesGroups::const_iterator i(specs_with_values_groups.begin()), - i_end(specs_with_values_groups.end()) ; - i != i_end ; ++i) + for (const auto & specs_with_values_group : specs_with_values_groups) { if (maybe_id) { - if (! match_package(*env, i->spec(), maybe_id, nullptr, { })) + if (! match_package(*env, specs_with_values_group.spec(), maybe_id, nullptr, { })) continue; } else { - if (! match_anything(i->spec())) + if (! match_anything(specs_with_values_group.spec())) continue; } - check_values_groups(env, maybe_id, prefix, unprefixed_name, i->values_groups(), + check_values_groups(env, maybe_id, prefix, unprefixed_name, specs_with_values_group.values_groups(), seen_minus_star, result_state, result_value); } } @@ -447,22 +442,20 @@ namespace const SpecsWithValuesGroups & specs_with_values_groups, const std::shared_ptr<Set<UnprefixedChoiceName> > & known) { - for (SpecsWithValuesGroups::const_iterator i(specs_with_values_groups.begin()), - i_end(specs_with_values_groups.end()) ; - i != i_end ; ++i) + for (const auto & specs_with_values_group : specs_with_values_groups) { if (maybe_id) { - if (! match_package(*env, i->spec(), maybe_id, nullptr, { })) + if (! match_package(*env, specs_with_values_group.spec(), maybe_id, nullptr, { })) continue; } else { - if (! match_anything(i->spec())) + if (! match_anything(specs_with_values_group.spec())) continue; } - collect_known_from_values_groups(env, maybe_id, prefix, i->values_groups(), known); + collect_known_from_values_groups(env, maybe_id, prefix, specs_with_values_group.values_groups(), known); } } } diff --git a/paludis/partitioning.cc b/paludis/partitioning.cc index afb3a0d06..c43bcd499 100644 --- a/paludis/partitioning.cc +++ b/paludis/partitioning.cc @@ -46,9 +46,8 @@ Partitioning::~Partitioning() = default; void Partitioning::mark(const std::vector<FSPath> & paths, const PartName & name) { - for (auto path = paths.begin(), path_end = paths.end(); - path != path_end; ++path) - _imp->parts.push_back(std::make_pair(*path, name)); + for (const auto & path : paths) + _imp->parts.push_back(std::make_pair(path, name)); } PartName diff --git a/paludis/repositories/e/can_skip_phase.cc b/paludis/repositories/e/can_skip_phase.cc index afd951e18..4abe3c73f 100644 --- a/paludis/repositories/e/can_skip_phase.cc +++ b/paludis/repositories/e/can_skip_phase.cc @@ -48,10 +48,9 @@ paludis::erepository::can_skip_phase( tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(skipifno, ",", "", inserter(skip_if_no_values, skip_if_no_values.begin())); - for (std::set<std::string>::const_iterator i(skip_if_no_values.begin()), i_end(skip_if_no_values.end()) ; - i != i_end ; ++i) + for (const auto & skip_if_no_value : skip_if_no_values) { - if (*i == "*sources") + if (skip_if_no_value == "*sources") { if (id->fetches_key()) { @@ -80,7 +79,7 @@ paludis::erepository::can_skip_phase( else { auto d(id->defined_phases_key()->parse_value()); - if (d->end() != d->find(*i)) + if (d->end() != d->find(skip_if_no_value)) return false; } } diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index ad49f4871..550904edd 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -494,9 +494,8 @@ namespace continue; case dsak_expandable: - for (auto c(children.begin()), c_end(children.end()) ; - c != c_end ; ++c) - add_expanded_annotation(eapi, *c, *a); + for (const auto & c : children) + add_expanded_annotation(eapi, c, *a); continue; case last_dsak: @@ -553,9 +552,8 @@ paludis::erepository::parse_depend(const std::string & s, const Environment * co parse_elike_dependencies(s, callbacks, { }); - for (auto b(stack.begin()->block_children().begin()), b_end(stack.begin()->block_children().end()) ; - b != b_end ; ++b) - add_synthetic_block_annotations(eapi, b->first, b->second); + for (auto & b : stack.begin()->block_children()) + add_synthetic_block_annotations(eapi, b.first, b.second); return top; } @@ -604,9 +602,8 @@ paludis::erepository::parse_commented_set(const std::string & s, const Environme parse_elike_dependencies(s, callbacks, { edpo_allow_embedded_comments }); - for (auto b(stack.begin()->block_children().begin()), b_end(stack.begin()->block_children().end()) ; - b != b_end ; ++b) - add_synthetic_block_annotations(eapi, b->first, b->second); + for (auto & b : stack.begin()->block_children()) + add_synthetic_block_annotations(eapi, b.first, b.second); return top; } diff --git a/paludis/repositories/e/do_install_action.cc b/paludis/repositories/e/do_install_action.cc index 5730e2e51..efb7f024b 100644 --- a/paludis/repositories/e/do_install_action.cc +++ b/paludis/repositories/e/do_install_action.cc @@ -203,13 +203,12 @@ paludis::erepository::do_install_action( { std::vector<std::string> tokens; tokenise_whitespace(id->eapi()->supported()->permitted_directories(), std::back_inserter(tokens)); - for (auto t(tokens.begin()), t_end(tokens.end()) ; - t != t_end ; ++t) + for (auto & token : tokens) { - if (t->at(0) == '-') - permitted_directories->add(FSPath(t->substr(1)), false); - else if (t->at(0) == '+') - permitted_directories->add(FSPath(t->substr(1)), true); + if (token.at(0) == '-') + permitted_directories->add(FSPath(token.substr(1)), false); + else if (token.at(0) == '+') + permitted_directories->add(FSPath(token.substr(1)), true); else throw InternalError(PALUDIS_HERE, "bad permitted_directories"); } diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc index 1e33b8c81..e55570b1a 100644 --- a/paludis/repositories/e/e_choices_key.cc +++ b/paludis/repositories/e/e_choices_key.cc @@ -605,15 +605,14 @@ EChoicesKey::populate_iuse(const std::shared_ptr<const Map<ChoiceNameWithPrefix, if (IsExpand(i->first, delim)(*u)) values.insert(UnprefixedChoiceName(i->first.value().substr(u->length() + delim.length()))); - for (std::set<UnprefixedChoiceName>::const_iterator v(values.begin()), v_end(values.end()) ; - v != v_end ; ++v) + for (const auto & value : values) { - std::map<ChoiceNameWithPrefix, ChoiceOptions>::const_iterator i(i_values.find(ChoiceNameWithPrefix(lower_u + delim + stringify(*v)))); + std::map<ChoiceNameWithPrefix, ChoiceOptions>::const_iterator i(i_values.find(ChoiceNameWithPrefix(lower_u + delim + stringify(value)))); if (i_values.end() != i) - exp->add(_imp->id->make_choice_value(exp, *v, i->second.default_value(), false, i->second.implicit() ? co_implicit : co_explicit, + exp->add(_imp->id->make_choice_value(exp, value, i->second.default_value(), false, i->second.implicit() ? co_implicit : co_explicit, get_maybe_description(d, i->first), false, false)); else - exp->add(_imp->id->make_choice_value(exp, *v, indeterminate, false, co_implicit, "", false, false)); + exp->add(_imp->id->make_choice_value(exp, value, indeterminate, false, co_implicit, "", false, false)); } } } diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index 91fc3f279..6264d4b1f 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -1362,34 +1362,32 @@ ERepository::repository_factory_create( std::vector<std::string> sync_tokens; tokenise_whitespace(f("sync"), std::back_inserter(sync_tokens)); std::string source; - for (auto t(sync_tokens.begin()), t_end(sync_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_token : sync_tokens) + if ((! sync_token.empty()) && (':' == sync_token.at(sync_token.length() - 1))) + source = sync_token.substr(0, sync_token.length() - 1); else { std::string v; if (sync->end() != sync->find(source)) v = sync->find(source)->second + " "; sync->erase(source); - sync->insert(source, v + *t); + sync->insert(source, v + sync_token); } auto sync_options(std::make_shared<Map<std::string, std::string> >()); std::vector<std::string> sync_options_tokens; tokenise_whitespace(f("sync_options"), std::back_inserter(sync_options_tokens)); source = ""; - for (auto t(sync_options_tokens.begin()), t_end(sync_options_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_options_token : sync_options_tokens) + if ((! sync_options_token.empty()) && (':' == sync_options_token.at(sync_options_token.length() - 1))) + source = sync_options_token.substr(0, sync_options_token.length() - 1); else { std::string v; if (sync_options->end() != sync_options->find(source)) v = sync_options->find(source)->second + " "; sync_options->erase(source); - sync_options->insert(source, v + *t); + sync_options->insert(source, v + sync_options_token); } std::string builddir(f("builddir")); @@ -1868,16 +1866,15 @@ ERepository::merge(const MergeParams & m) } if (_imp->params.write_cache() != FSPath("/var/empty")) - for (auto r(replaces.begin()), r_end(replaces.end()) ; - r != r_end ; ++r) + for (auto & replace : replaces) { FSPath cache(_imp->params.write_cache()); if (_imp->params.append_repository_name_to_write_cache()) cache /= stringify(name()); - cache /= stringify((*r)->name().category()); - cache /= (stringify((*r)->name().package()) + "-" + stringify((*r)->version())); + cache /= stringify(replace->name().category()); + cache /= (stringify(replace->name().package()) + "-" + stringify(replace->version())); if (cache.stat().is_regular_file_or_symlink_to_regular_file()) { diff --git a/paludis/repositories/e/eapi_phase.cc b/paludis/repositories/e/eapi_phase.cc index 5296da545..c6277dedd 100644 --- a/paludis/repositories/e/eapi_phase.cc +++ b/paludis/repositories/e/eapi_phase.cc @@ -90,10 +90,9 @@ EAPIPhase::option(const std::string & s) const std::string EAPIPhase::equal_option(const std::string & s) const { - for (std::set<std::string>::const_iterator i(_imp->options.begin()), i_end(_imp->options.end()) ; - i != i_end ; ++i) - if (0 == i->compare(0, s.length() + 1, s + "=")) - return i->substr(s.length() + 1); + for (const auto & option : _imp->options) + if (0 == option.compare(0, s.length() + 1, s + "=")) + return option.substr(s.length() + 1); return ""; } diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc index b5f9c8fde..502301fc3 100644 --- a/paludis/repositories/e/exheres_layout.cc +++ b/paludis/repositories/e/exheres_layout.cc @@ -591,24 +591,23 @@ namespace return; std::list<FSPath> files((FSIterator(d, { })), FSIterator()); - for (std::list<FSPath>::iterator f(files.begin()) ; - f != files.end() ; ++f) + for (auto & file : files) { - FSStat f_stat(f->stat()); + FSStat f_stat(file.stat()); if (f_stat.is_directory()) { - if ("CVS" != f->basename()) - aux_files_helper((*f), m, qpn); + if ("CVS" != file.basename()) + aux_files_helper(file, m, qpn); } else { if (! f_stat.is_regular_file()) continue; - if (is_file_with_prefix_extension((*f), + if (is_file_with_prefix_extension(file, ("digest-"+stringify(qpn.package())), "", { })) continue; - m->insert((*f), "AUX"); + m->insert(file, "AUX"); } } } @@ -620,18 +619,17 @@ ExheresLayout::manifest_files(const QualifiedPackageName & qpn, const FSPath & p auto result(std::make_shared<Map<FSPath, std::string, FSPathComparator>>()); std::list<FSPath> package_files((FSIterator(package_dir, { })), FSIterator()); - for (std::list<FSPath>::iterator f(package_files.begin()) ; - f != package_files.end() ; ++f) + for (auto & package_file : package_files) { - FSStat f_stat(f->stat()); - if (! f_stat.is_regular_file() || ((*f).basename() == "Manifest") ) + FSStat f_stat(package_file.stat()); + if (! f_stat.is_regular_file() || (package_file.basename() == "Manifest") ) continue; std::string file_type("MISC"); - if (FileSuffixes::get_instance()->is_package_file(qpn, (*f))) - file_type = FileSuffixes::get_instance()->get_package_file_manifest_key((*f), qpn); + if (FileSuffixes::get_instance()->is_package_file(qpn, package_file)) + file_type = FileSuffixes::get_instance()->get_package_file_manifest_key(package_file, qpn); - result->insert((*f), file_type); + result->insert(package_file, file_type); } aux_files_helper((package_dir / "files"), result, qpn); diff --git a/paludis/repositories/e/exheres_mask_store.cc b/paludis/repositories/e/exheres_mask_store.cc index 5813c0e90..6b2b70db9 100644 --- a/paludis/repositories/e/exheres_mask_store.cc +++ b/paludis/repositories/e/exheres_mask_store.cc @@ -189,9 +189,9 @@ ExheresMaskStore::query(const std::shared_ptr<const PackageID> & id) const auto result(std::make_shared<MasksInfo>()); auto r(_imp->repo_mask.find(id->name())); if (_imp->repo_mask.end() != r) - for (auto k(r->second.begin()), k_end(r->second.end()) ; k != k_end ; ++k) - if (match_package(*_imp->env, k->first, id, nullptr, { })) - result->push_back(*k->second); + for (const auto & k : r->second) + if (match_package(*_imp->env, k.first, id, nullptr, { })) + result->push_back(*k.second); return result; } diff --git a/paludis/repositories/e/myoptions_requirements_verifier.cc b/paludis/repositories/e/myoptions_requirements_verifier.cc index a47d35783..7abddcfc2 100644 --- a/paludis/repositories/e/myoptions_requirements_verifier.cc +++ b/paludis/repositories/e/myoptions_requirements_verifier.cc @@ -257,9 +257,8 @@ MyOptionsRequirementsVerifier::visit(const PlainTextSpecTree::NodeType<PlainText std::shared_ptr<const ChoiceValue> choice_value(find_choice_value(_imp->id, *_imp->current_prefix_stack.begin(), active_flag)); if (choice_value && choice_value->enabled() == active_myoption.second) - for (std::list<int>::iterator l(_imp->number_enabled_stack.begin()), l_end(_imp->number_enabled_stack.end()) ; - l != l_end ; ++l) - ++*l; + for (int & l : _imp->number_enabled_stack) + ++l; } if ((! node.spec()->maybe_annotations()) || (node.spec()->maybe_annotations()->begin() == node.spec()->maybe_annotations()->end())) diff --git a/paludis/repositories/e/parse_dependency_label.cc b/paludis/repositories/e/parse_dependency_label.cc index 9f4588858..021cc3e06 100644 --- a/paludis/repositories/e/parse_dependency_label.cc +++ b/paludis/repositories/e/parse_dependency_label.cc @@ -176,11 +176,11 @@ paludis::erepository::parse_dependency_label( std::shared_ptr<DependenciesLabelsDepSpec> l(std::make_shared<DependenciesLabelsDepSpec>()); - for (std::set<std::string>::iterator it = labels.begin(), it_e = labels.end(); it != it_e; ++it) + for (const auto & label : labels) { - std::string c(e.supported()->dependency_labels()->class_for_label(*it)), cc; + std::string c(e.supported()->dependency_labels()->class_for_label(label)), cc; if (c.empty()) - throw EDepParseError(s, "Unknown label '" + *it + "'"); + throw EDepParseError(s, "Unknown label '" + label + "'"); std::string::size_type p(c.find('/')); if (std::string::npos != p) @@ -192,12 +192,12 @@ paludis::erepository::parse_dependency_label( if (c == "DependenciesTestLabel") { if (cc.empty()) - l->add_label(DepLabelsStore::get_instance()->get(e.name(), c, *it)); + l->add_label(DepLabelsStore::get_instance()->get(e.name(), c, label)); else - l->add_label(DepLabelsStore::get_instance()->get_test(e.name(), c, ChoiceNameWithPrefix(cc), *it)); + l->add_label(DepLabelsStore::get_instance()->get_test(e.name(), c, ChoiceNameWithPrefix(cc), label)); } else - l->add_label(DepLabelsStore::get_instance()->get(e.name(), c, *it)); + l->add_label(DepLabelsStore::get_instance()->get(e.name(), c, label)); } return l; diff --git a/paludis/repositories/e/permitted_directories.cc b/paludis/repositories/e/permitted_directories.cc index bb2d76f8a..204b0b4da 100644 --- a/paludis/repositories/e/permitted_directories.cc +++ b/paludis/repositories/e/permitted_directories.cc @@ -53,10 +53,9 @@ PermittedDirectories::permit(const FSPath & p) const { bool result(true); - for (auto r(_imp->rules.begin()), r_end(_imp->rules.end()) ; - r != r_end ; ++r) - if (p.starts_with(r->first)) - result = r->second; + for (const auto & rule : _imp->rules) + if (p.starts_with(rule.first)) + result = rule.second; return result; } diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc index 6d8b56865..33b78a06e 100644 --- a/paludis/repositories/e/traditional_layout.cc +++ b/paludis/repositories/e/traditional_layout.cc @@ -608,24 +608,23 @@ namespace return; std::list<FSPath> files((FSIterator(d, { fsio_inode_sort })), FSIterator()); - for (std::list<FSPath>::iterator f(files.begin()) ; - f != files.end() ; ++f) + for (auto & file : files) { - FSStat f_stat(f->stat()); + FSStat f_stat(file.stat()); if (f_stat.is_directory()) { - if ("CVS" != f->basename()) - aux_files_helper((*f), m, qpn); + if ("CVS" != file.basename()) + aux_files_helper(file, m, qpn); } else { if (! f_stat.is_regular_file()) continue; - if (is_file_with_prefix_extension((*f), + if (is_file_with_prefix_extension(file, ("digest-"+stringify(qpn.package())), "", { })) continue; - m->insert((*f), "AUX"); + m->insert(file, "AUX"); } } } @@ -637,17 +636,16 @@ TraditionalLayout::manifest_files(const QualifiedPackageName & qpn, const FSPath auto result(std::make_shared<Map<FSPath, std::string, FSPathComparator>>()); std::list<FSPath> package_files((FSIterator(package_dir, { fsio_inode_sort, fsio_want_regular_files })), FSIterator()); - for (std::list<FSPath>::iterator f(package_files.begin()) ; - f != package_files.end() ; ++f) + for (auto & package_file : package_files) { - if ((*f).basename() == "Manifest") + if (package_file.basename() == "Manifest") continue; std::string file_type("MISC"); - if (FileSuffixes::get_instance()->is_package_file(qpn, (*f))) - file_type = FileSuffixes::get_instance()->get_package_file_manifest_key((*f), qpn); + if (FileSuffixes::get_instance()->is_package_file(qpn, package_file)) + file_type = FileSuffixes::get_instance()->get_package_file_manifest_key(package_file, qpn); - result->insert((*f), file_type); + result->insert(package_file, file_type); } aux_files_helper((package_dir / "files"), result, qpn); diff --git a/paludis/repositories/e/traditional_mask_store.cc b/paludis/repositories/e/traditional_mask_store.cc index 3017bcdbc..66d72c207 100644 --- a/paludis/repositories/e/traditional_mask_store.cc +++ b/paludis/repositories/e/traditional_mask_store.cc @@ -123,9 +123,9 @@ TraditionalMaskStore::query(const std::shared_ptr<const PackageID> & id) const auto result(std::make_shared<MasksInfo>()); auto r(_imp->repo_mask.find(id->name())); if (_imp->repo_mask.end() != r) - for (auto k(r->second.begin()), k_end(r->second.end()) ; k != k_end ; ++k) - if (match_package(*_imp->env, k->first, id, nullptr, { })) - result->push_back(*k->second); + for (const auto & k : r->second) + if (match_package(*_imp->env, k.first, id, nullptr, { })) + result->push_back(*k.second); return result; } diff --git a/paludis/repositories/e/traditional_profile.cc b/paludis/repositories/e/traditional_profile.cc index 567b9b56b..46e4d4d25 100644 --- a/paludis/repositories/e/traditional_profile.cc +++ b/paludis/repositories/e/traditional_profile.cc @@ -827,27 +827,25 @@ TraditionalProfile::use_masked( result = fs->second; } - for (PackageFlagStatusMapList::const_iterator g(i->package_use_mask.begin()), - g_end(i->package_use_mask.end()) ; g != g_end ; ++g) + for (const auto & g : i->package_use_mask) { - if (! match_package(*_imp->env, *g->first, id, nullptr, { })) + if (! match_package(*_imp->env, *g.first, id, nullptr, { })) continue; - FlagStatusMap::const_iterator h(g->second.find(value_prefixed)); - if (g->second.end() != h) + FlagStatusMap::const_iterator h(g.second.find(value_prefixed)); + if (g.second.end() != h) result = h->second; } if (id->is_stable()) { - for (PackageFlagStatusMapList::const_iterator gs(i->package_use_stable_mask.begin()), - gs_end(i->package_use_stable_mask.end()) ; gs != gs_end ; ++gs) + for (const auto & gs : i->package_use_stable_mask) { - if (! match_package(*_imp->env, *gs->first, id, nullptr, { })) + if (! match_package(*_imp->env, *gs.first, id, nullptr, { })) continue; - FlagStatusMap::const_iterator hs(gs->second.find(value_prefixed)); - if (gs->second.end() != hs) + FlagStatusMap::const_iterator hs(gs.second.find(value_prefixed)); + if (gs.second.end() != hs) result = hs->second; } } @@ -884,27 +882,25 @@ TraditionalProfile::use_forced( result = fs->second; } - for (PackageFlagStatusMapList::const_iterator g(i->package_use_force.begin()), - g_end(i->package_use_force.end()) ; g != g_end ; ++g) + for (const auto & g : i->package_use_force) { - if (! match_package(*_imp->env, *g->first, id, nullptr, { })) + if (! match_package(*_imp->env, *g.first, id, nullptr, { })) continue; - FlagStatusMap::const_iterator h(g->second.find(value_prefixed)); - if (g->second.end() != h) + FlagStatusMap::const_iterator h(g.second.find(value_prefixed)); + if (g.second.end() != h) result = h->second; } if (id->is_stable()) { - for (PackageFlagStatusMapList::const_iterator gs(i->package_use_stable_force.begin()), - gs_end(i->package_use_stable_force.end()) ; gs != gs_end ; ++gs) + for (const auto & gs : i->package_use_stable_force) { - if (! match_package(*_imp->env, *gs->first, id, nullptr, { })) + if (! match_package(*_imp->env, *gs.first, id, nullptr, { })) continue; - FlagStatusMap::const_iterator hs(gs->second.find(value_prefixed)); - if (gs->second.end() != hs) + FlagStatusMap::const_iterator hs(gs.second.find(value_prefixed)); + if (gs.second.end() != hs) result = hs->second; } } @@ -927,14 +923,13 @@ TraditionalProfile::use_state_ignoring_masks( for (StackedValuesList::const_iterator i(_imp->stacked_values_list.begin()), i_end(_imp->stacked_values_list.end()) ; i != i_end ; ++i) { - for (PackageFlagStatusMapList::const_iterator g(i->package_use.begin()), - g_end(i->package_use.end()) ; g != g_end ; ++g) + for (const auto & g : i->package_use) { - if (! match_package(*_imp->env, *g->first, id, nullptr, { })) + if (! match_package(*_imp->env, *g.first, id, nullptr, { })) continue; - FlagStatusMap::const_iterator h(g->second.find(value_prefixed)); - if (g->second.end() != h) + FlagStatusMap::const_iterator h(g.second.find(value_prefixed)); + if (g.second.end() != h) result = h->second ? true : false; } } @@ -1029,10 +1024,9 @@ TraditionalProfile::profile_masks(const std::shared_ptr<const PackageID> & id) c PackageMaskMap::const_iterator rr(_imp->package_mask.find(id->name())); if (_imp->package_mask.end() != rr) { - for (std::list<std::pair<std::shared_ptr<const PackageDepSpec>, std::shared_ptr<const MaskInfo> > >::const_iterator k(rr->second.begin()), - k_end(rr->second.end()) ; k != k_end ; ++k) - if (match_package(*_imp->env, *k->first, id, nullptr, { })) - result->push_back(*k->second); + for (const auto & k : rr->second) + if (match_package(*_imp->env, *k.first, id, nullptr, { })) + result->push_back(*k.second); } return result; diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc index a0da0bed5..aad388325 100644 --- a/paludis/repositories/unavailable/unavailable_repository.cc +++ b/paludis/repositories/unavailable/unavailable_repository.cc @@ -343,34 +343,32 @@ UnavailableRepository::repository_factory_create( std::vector<std::string> sync_tokens; tokenise_whitespace(f("sync"), std::back_inserter(sync_tokens)); std::string source; - for (auto t(sync_tokens.begin()), t_end(sync_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_token : sync_tokens) + if ((! sync_token.empty()) && (':' == sync_token.at(sync_token.length() - 1))) + source = sync_token.substr(0, sync_token.length() - 1); else { std::string v; if (sync->end() != sync->find(source)) v = sync->find(source)->second + " "; sync->erase(source); - sync->insert(source, v + *t); + sync->insert(source, v + sync_token); } auto sync_options(std::make_shared<Map<std::string, std::string> >()); std::vector<std::string> sync_options_tokens; tokenise_whitespace(f("sync_options"), std::back_inserter(sync_options_tokens)); source = ""; - for (auto t(sync_options_tokens.begin()), t_end(sync_options_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_options_token : sync_options_tokens) + if ((! sync_options_token.empty()) && (':' == sync_options_token.at(sync_options_token.length() - 1))) + source = sync_options_token.substr(0, sync_options_token.length() - 1); else { std::string v; if (sync_options->end() != sync_options->find(source)) v = sync_options->find(source)->second + " "; sync_options->erase(source); - sync_options->insert(source, v + *t); + sync_options->insert(source, v + sync_options_token); } return std::make_shared<UnavailableRepository>( diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc index c0b21de74..a1bbf3142 100644 --- a/paludis/repositories/unwritten/unwritten_repository.cc +++ b/paludis/repositories/unwritten/unwritten_repository.cc @@ -299,34 +299,32 @@ UnwrittenRepository::repository_factory_create( std::vector<std::string> sync_tokens; tokenise_whitespace(f("sync"), std::back_inserter(sync_tokens)); std::string source; - for (auto t(sync_tokens.begin()), t_end(sync_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_token : sync_tokens) + if ((! sync_token.empty()) && (':' == sync_token.at(sync_token.length() - 1))) + source = sync_token.substr(0, sync_token.length() - 1); else { std::string v; if (sync->end() != sync->find(source)) v = sync->find(source)->second + " "; sync->erase(source); - sync->insert(source, v + *t); + sync->insert(source, v + sync_token); } auto sync_options(std::make_shared<Map<std::string, std::string> >()); std::vector<std::string> sync_options_tokens; tokenise_whitespace(f("sync_options"), std::back_inserter(sync_options_tokens)); source = ""; - for (auto t(sync_options_tokens.begin()), t_end(sync_options_tokens.end()) ; - t != t_end ; ++t) - if ((! t->empty()) && (':' == t->at(t->length() - 1))) - source = t->substr(0, t->length() - 1); + for (auto & sync_options_token : sync_options_tokens) + if ((! sync_options_token.empty()) && (':' == sync_options_token.at(sync_options_token.length() - 1))) + source = sync_options_token.substr(0, sync_options_token.length() - 1); else { std::string v; if (sync_options->end() != sync_options->find(source)) v = sync_options->find(source)->second + " "; sync_options->erase(source); - sync_options->insert(source, v + *t); + sync_options->insert(source, v + sync_options_token); } return std::make_shared<UnwrittenRepository>( diff --git a/paludis/resolver/find_replacing_helper.cc b/paludis/resolver/find_replacing_helper.cc index dafe3b6bf..98c869615 100644 --- a/paludis/resolver/find_replacing_helper.cc +++ b/paludis/resolver/find_replacing_helper.cc @@ -95,12 +95,10 @@ FindReplacingHelper::operator() ( repos.insert(repo->name()); std::shared_ptr<PackageIDSequence> result(std::make_shared<PackageIDSequence>()); - for (std::set<RepositoryName>::const_iterator r(repos.begin()), - r_end(repos.end()) ; - r != r_end ; ++r) + for (const auto & r : repos) { std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsUnsorted( - generator::Package(id->name()) & generator::InRepository(*r))]); + generator::Package(id->name()) & generator::InRepository(r))]); for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ; i != i_end ; ++i) { diff --git a/paludis/resolver/get_initial_constraints_for_helper.cc b/paludis/resolver/get_initial_constraints_for_helper.cc index 463086063..8a7de9567 100644 --- a/paludis/resolver/get_initial_constraints_for_helper.cc +++ b/paludis/resolver/get_initial_constraints_for_helper.cc @@ -214,9 +214,8 @@ namespace const QualifiedPackageName & name, const std::list<PackageDepSpec> & list) { - for (auto l(list.begin()), l_end(list.end()) ; - l != l_end ; ++l) - if (match_qpns(*env, *l, name)) + for (const auto & l : list) + if (match_qpns(*env, l, name)) return true; return false; } diff --git a/paludis/resolver/get_sameness.cc b/paludis/resolver/get_sameness.cc index 29c8a2ab7..6f95f083e 100644 --- a/paludis/resolver/get_sameness.cc +++ b/paludis/resolver/get_sameness.cc @@ -185,10 +185,9 @@ paludis::resolver::get_sameness( std::inserter(common, common.begin())); } - for (std::set<ChoiceNameWithPrefix>::const_iterator f(common.begin()), f_end(common.end()) ; - f != f_end ; ++f) - if (installable_choices->find_by_name_with_prefix(*f)->enabled() != - existing_choices->find_by_name_with_prefix(*f)->enabled()) + for (const auto & f : common) + if (installable_choices->find_by_name_with_prefix(f)->enabled() != + existing_choices->find_by_name_with_prefix(f)->enabled()) { is_same = false; is_same_metadata = false; diff --git a/paludis/resolver/get_use_existing_nothing_helper.cc b/paludis/resolver/get_use_existing_nothing_helper.cc index 6111d3ad9..f1416253d 100644 --- a/paludis/resolver/get_use_existing_nothing_helper.cc +++ b/paludis/resolver/get_use_existing_nothing_helper.cc @@ -105,9 +105,8 @@ namespace const QualifiedPackageName & name, const std::list<PackageDepSpec> & list) { - for (auto l(list.begin()), l_end(list.end()) ; - l != l_end ; ++l) - if (match_qpns(*env, *l, name)) + for (const auto & l : list) + if (match_qpns(*env, l, name)) return true; return false; } diff --git a/paludis/resolver/nag.cc b/paludis/resolver/nag.cc index 587243b5a..31a09e64f 100644 --- a/paludis/resolver/nag.cc +++ b/paludis/resolver/nag.cc @@ -197,16 +197,15 @@ namespace Edges::const_iterator e(edges.find(node)); if (e != edges.end()) { - for (NodesWithProperties::const_iterator n(e->second.begin()), n_end(e->second.end()) ; - n != n_end ; ++n) + for (const auto & n : e->second) { - TarjanDataMap::iterator n_data(data.find(n->first)); + TarjanDataMap::iterator n_data(data.find(n.first)); if (data.end() == n_data) { - n_data = tarjan(n->first, edges, data, stack, index, result); + n_data = tarjan(n.first, edges, data, stack, index, result); node_data->second.lowlink() = std::min(node_data->second.lowlink(), n_data->second.lowlink()); } - else if (stack.end() != std::find(stack.begin(), stack.end(), n->first)) + else if (stack.end() != std::find(stack.begin(), stack.end(), n.first)) node_data->second.lowlink() = std::min(node_data->second.lowlink(), n_data->second.index()); } } @@ -302,14 +301,12 @@ NAG::sorted_strongly_connected_components( /* build edges between SCCs */ PlainEdges all_scc_edges, scc_edges, scc_edges_backwards; - for (Edges::const_iterator e(_imp->edges.begin()), e_end(_imp->edges.end()) ; - e != e_end ; ++e) + for (const auto & edge : _imp->edges) { - RepresentativeNodes::const_iterator from(representative_nodes.find(e->first)); - for (NodesWithProperties::const_iterator n(e->second.begin()), n_end(e->second.end()) ; - n != n_end ; ++n) + RepresentativeNodes::const_iterator from(representative_nodes.find(edge.first)); + for (const auto & n : edge.second) { - RepresentativeNodes::const_iterator to(representative_nodes.find(n->first)); + RepresentativeNodes::const_iterator to(representative_nodes.find(n.first)); if (! (to->second == from->second)) { all_scc_edges.insert(std::make_pair(from->second, Nodes())).first->second.insert(to->second); @@ -344,13 +341,12 @@ NAG::sorted_strongly_connected_components( auto this_scc_edges(all_scc_edges.find(ordering_now->second)); if (this_scc_edges != all_scc_edges.end()) { - for (auto e(this_scc_edges->second.begin()), e_end(this_scc_edges->second.end()) ; - e != e_end ; ++e) + for (const auto & e : this_scc_edges->second) { - auto p(pending_fetches.find(*e)); + auto p(pending_fetches.find(e)); if (p != pending_fetches.end()) { - result->push_back(sccs.find(*e)->second); + result->push_back(sccs.find(e)->second); pending_fetches.erase(p); } } @@ -431,14 +427,13 @@ NAG::serialise(Serialiser & s) const w.member(SerialiserFlags<serialise::container>(), "nodes", _imp->nodes); int c(0); - for (Edges::const_iterator e(_imp->edges.begin()), e_end(_imp->edges.end()) ; - e != e_end ; ++e) + for (const auto & edge : _imp->edges) { - for (NodesWithProperties::const_iterator n(e->second.begin()), n_end(e->second.end()) ; + for (NodesWithProperties::const_iterator n(edge.second.begin()), n_end(edge.second.end()) ; n != n_end ; ++n) { ++c; - w.member(SerialiserFlags<>(), "edge." + stringify(c) + ".f", e->first); + w.member(SerialiserFlags<>(), "edge." + stringify(c) + ".f", edge.first); w.member(SerialiserFlags<>(), "edge." + stringify(c) + ".t", n->first); w.member(SerialiserFlags<>(), "edge." + stringify(c) + ".p", n->second); } diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc index 1954c0ad5..0ac5969d6 100644 --- a/paludis/resolver/sanitised_dependencies.cc +++ b/paludis/resolver/sanitised_dependencies.cc @@ -274,15 +274,14 @@ namespace std::pair<AnyChildScore, OperatorScore> worst_score(acs_better_than_best, os_better_than_best); /* score of a group is the score of the worst child. */ - for (std::list<PackageOrBlockDepSpec>::const_iterator h(g->begin()), h_end(g->end()) ; - h != h_end ; ++h) + for (const auto & h : *g) { - auto s(maybe_make_sanitised(PackageOrBlockDepSpec(*h))); + auto s(maybe_make_sanitised(PackageOrBlockDepSpec(h))); if (s) { auto score(decider.find_any_score(our_resolution, our_id, *s)); Log::get_instance()->message("resolver.sanitised_dependencies.any_score", ll_debug, lc_context) - << "Scored " << *h << " as " << score.first << " " << score.second; + << "Scored " << h << " as " << score.first << " " << score.second; if (score < worst_score) worst_score = score; @@ -299,10 +298,9 @@ namespace if (g_best != child_groups.end()) { /* might be nothing to do, if no labels are enabled */ - for (std::list<PackageOrBlockDepSpec>::const_iterator h(g_best->begin()), h_end(g_best->end()) ; - h != h_end ; ++h) + for (const auto & h : *g_best) { - auto s(maybe_make_sanitised(*h)); + auto s(maybe_make_sanitised(h)); if (s) apply(*s); } @@ -370,9 +368,8 @@ namespace auto classifier(classifier_builder->create()); if (classifier->any_enabled) { - for (auto c(conditions_stack.begin()), c_end(conditions_stack.end()) ; - c != c_end ; ++c) - acs << (acs.str().empty() ? "" : ", ") << stringify(*c); + for (auto & c : conditions_stack) + acs << (acs.str().empty() ? "" : ", ") << stringify(c); return make_shared_copy(make_named_values<SanitisedDependency>( n::active_conditions_as_string() = acs.str(), diff --git a/paludis/selection.cc b/paludis/selection.cc index 9a6e6325c..74e7c5f4b 100644 --- a/paludis/selection.cc +++ b/paludis/selection.cc @@ -326,9 +326,8 @@ namespace } PackageIDComparator comparator(env); - for (SlotMap::iterator i(by_slot.begin()), i_end(by_slot.end()) ; - i != i_end ; ++i) - i->second->sort(comparator); + for (auto & i : by_slot) + i.second->sort(comparator); while (! by_slot.empty()) { @@ -393,9 +392,8 @@ namespace } PackageIDComparator comparator(env); - for (SlotMap::iterator i(by_slot.begin()), i_end(by_slot.end()) ; - i != i_end ; ++i) - i->second->sort(comparator); + for (auto & i : by_slot) + i.second->sort(comparator); while (! by_slot.empty()) { diff --git a/paludis/serialise.cc b/paludis/serialise.cc index 24f18beec..6d17c36a6 100644 --- a/paludis/serialise.cc +++ b/paludis/serialise.cc @@ -102,9 +102,8 @@ SerialiserObjectWriterHandler<false, false, const PackageID>::write(Serialiser & void Serialiser::escape_write(const std::string & t) { - for (std::string::const_iterator c(t.begin()), c_end(t.end()) ; - c != c_end ; ++c) - switch (*c) + for (char c : t) + switch (c) { case '\\': case '"': @@ -114,7 +113,7 @@ Serialiser::escape_write(const std::string & t) raw_stream() << '\\'; /* fall through */ default: - raw_stream() << *c; + raw_stream() << c; } } diff --git a/paludis/set_file.cc b/paludis/set_file.cc index 313a22a2e..00a5747f7 100644 --- a/paludis/set_file.cc +++ b/paludis/set_file.cc @@ -319,27 +319,26 @@ SimpleHandler::_create_contents() const Context context("When parsing atoms in simple set file '" + stringify(_p.file_name()) + "':"); _contents = std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>()); - for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; - i != i_end ; ++i) + for (const auto & _line : _lines) { - if (i->empty()) + if (_line.empty()) continue; - if ('#' == i->at(0)) + if ('#' == _line.at(0)) continue; - Context c("When handling line '" + stringify(*i) + "':"); + Context c("When handling line '" + stringify(_line) + "':"); try { - if (std::string::npos == i->find('/')) + if (std::string::npos == _line.find('/')) { - std::shared_ptr<NamedSetDepSpec> p(std::make_shared<NamedSetDepSpec>(SetName(*i))); + std::shared_ptr<NamedSetDepSpec> p(std::make_shared<NamedSetDepSpec>(SetName(_line))); _contents->top()->append(p); } else { - std::shared_ptr<PackageDepSpec> p(std::make_shared<PackageDepSpec>(_p.parser()(stringify(*i)))); + std::shared_ptr<PackageDepSpec> p(std::make_shared<PackageDepSpec>(_p.parser()(stringify(_line)))); _contents->top()->append(p); } } @@ -350,7 +349,7 @@ SimpleHandler::_create_contents() const catch (const Exception & e) { Log::get_instance()->message("set_file.ignoring_line", ll_warning, lc_context) - << "Ignoring line '" << *i << "' due to exception '" << e.message() << "' (" << e.what() << "'"; + << "Ignoring line '" << _line << "' due to exception '" << e.message() << "' (" << e.what() << "'"; } } } @@ -417,9 +416,8 @@ SimpleHandler::rewrite() const { SafeOFStream f(_p.file_name(), -1, true); - for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; - i != i_end ; ++i) - f << *i << std::endl; + for (const auto & _line : _lines) + f << _line << std::endl; } catch (const SafeOFStreamError & e) { @@ -445,9 +443,8 @@ PaludisConfHandler::_create_contents() const Context context("When parsing atoms in paludis conf set file '" + stringify(_p.file_name()) + "':"); _contents = std::make_shared<SetSpecTree>(std::make_shared<AllDepSpec>()); - for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; - i != i_end ; ++i) - do_one_conf_line(*i, _contents, _p); + for (const auto & _line : _lines) + do_one_conf_line(_line, _contents, _p); } std::shared_ptr<SetSpecTree> @@ -510,9 +507,8 @@ PaludisConfHandler::rewrite() const { SafeOFStream f(_p.file_name(), -1, true); - for (std::list<std::string>::const_iterator i(_lines.begin()), i_end(_lines.end()) ; - i != i_end ; ++i) - f << *i << std::endl; + for (const auto & _line : _lines) + f << _line << std::endl; } catch (const SafeOFStreamError & e) { diff --git a/paludis/util/executor.cc b/paludis/util/executor.cc index 136de2eda..621146e51 100644 --- a/paludis/util/executor.cc +++ b/paludis/util/executor.cc @@ -157,9 +157,8 @@ Executor::execute() _imp->condition.wait_for(lock, std::chrono::milliseconds(_imp->ms_update_interval)); - for (Running::iterator r(running.begin()), r_end(running.end()) ; - r != r_end ; ++r) - r->second.second->flush_threaded(); + for (auto & r : running) + r.second.second->flush_threaded(); for (ReadyForPost::iterator p(_imp->ready_for_post.begin()), p_end(_imp->ready_for_post.end()) ; p != p_end ; ++p) diff --git a/paludis/util/md5.cc b/paludis/util/md5.cc index 727ee16b0..b736c9db8 100644 --- a/paludis/util/md5.cc +++ b/paludis/util/md5.cc @@ -187,9 +187,9 @@ MD5::hexsum() const { std::stringstream result; - for (int j(0) ; j < 4 ; ++j) + for (unsigned int j : _r) result << std::hex << std::right << std::setw(8) << std::setfill('0') << - _e(static_cast<unsigned int>(_r[j])) << std::flush; + _e(static_cast<unsigned int>(j)) << std::flush; return result.str(); } diff --git a/paludis/util/pool.cc b/paludis/util/pool.cc index 215629943..3332a24ac 100644 --- a/paludis/util/pool.cc +++ b/paludis/util/pool.cc @@ -86,11 +86,10 @@ PoolKeysHasher::operator() (const PoolKeys & keys) const { std::size_t result(0); - for (auto i(keys._imp->values->begin()), i_end(keys._imp->values->end()) ; - i != i_end ; ++i) + for (auto & i : *keys._imp->values) { result <<= 4; - result ^= (*i)->hash(); + result ^= i->hash(); } return result; diff --git a/paludis/util/process.cc b/paludis/util/process.cc index 380d671d6..fa9bf8902 100644 --- a/paludis/util/process.cc +++ b/paludis/util/process.cc @@ -794,9 +794,8 @@ Process::run() ::setenv("LINES", stringify(lines).c_str(), 1); } - for (auto m(_imp->setenvs.begin()), m_end(_imp->setenvs.end()) ; - m != m_end ; ++m) - ::setenv(m->first.c_str(), m->second.c_str(), 1); + for (auto & m : _imp->setenvs) + ::setenv(m.first.c_str(), m.second.c_str(), 1); if (! _imp->chdir.empty()) if (-1 == ::chdir(_imp->chdir.c_str())) diff --git a/paludis/util/rmd160.cc b/paludis/util/rmd160.cc index 394cf60c9..9e2f234c0 100644 --- a/paludis/util/rmd160.cc +++ b/paludis/util/rmd160.cc @@ -165,9 +165,9 @@ RMD160::hexsum() const { std::stringstream result; - for (int j(0) ; j < 5 ; ++j) + for (unsigned int j : _h) result << std::hex << std::right << std::setw(8) << std::setfill('0') << - _e(static_cast<unsigned int>(_h[j])) << std::flush; + _e(static_cast<unsigned int>(j)) << std::flush; return result.str(); } diff --git a/paludis/util/sha256.cc b/paludis/util/sha256.cc index b44b11fe5..ca198ea9a 100644 --- a/paludis/util/sha256.cc +++ b/paludis/util/sha256.cc @@ -182,9 +182,9 @@ SHA256::hexsum() const { std::stringstream result; - for (int j(0) ; j < 8 ; ++j) + for (unsigned int j : _h) result << std::hex << std::right << std::setw(8) << std::setfill('0') << - static_cast<unsigned int>(_h[j]) << std::flush; + static_cast<unsigned int>(j) << std::flush; return result.str(); } diff --git a/paludis/util/tee_output_stream.cc b/paludis/util/tee_output_stream.cc index 73b0ff1ad..d0ee0beb8 100644 --- a/paludis/util/tee_output_stream.cc +++ b/paludis/util/tee_output_stream.cc @@ -44,27 +44,24 @@ TeeOutputStreamBuf::~TeeOutputStreamBuf() TeeOutputStreamBuf::int_type TeeOutputStreamBuf::overflow(int_type c) { - for (std::list<std::ostream *>::iterator i(_imp->streams.begin()), i_end(_imp->streams.end()) ; - i != i_end ; ++i) - (*i)->put(c); + for (auto & stream : _imp->streams) + stream->put(c); return c; } int TeeOutputStreamBuf::sync() { - for (std::list<std::ostream *>::iterator i(_imp->streams.begin()), i_end(_imp->streams.end()) ; - i != i_end ; ++i) - **i << std::flush; + for (auto & stream : _imp->streams) + *stream << std::flush; return 0; } std::streamsize TeeOutputStreamBuf::xsputn(const char * s, std::streamsize num) { - for (std::list<std::ostream *>::iterator i(_imp->streams.begin()), i_end(_imp->streams.end()) ; - i != i_end ; ++i) - (*i)->write(s, num); + for (auto & stream : _imp->streams) + stream->write(s, num); return num; } diff --git a/paludis/util/whirlpool.cc b/paludis/util/whirlpool.cc index bbf4089cd..75ed86dee 100644 --- a/paludis/util/whirlpool.cc +++ b/paludis/util/whirlpool.cc @@ -455,8 +455,8 @@ Whirlpool::hexsum() const { std::stringstream result; result << std::hex << std::right << std::setfill('0'); - for (int i = 0; i < 8; ++i) - result << std::setw(16) << from_bigendian(H[i]); + for (unsigned long i : H) + result << std::setw(16) << from_bigendian(i); return result.str(); } diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc index 5b2fba576..a043fed8d 100644 --- a/paludis/version_spec.cc +++ b/paludis/version_spec.cc @@ -274,13 +274,12 @@ VersionSpec::VersionSpec(const std::string & text, const VersionSpecOptions & op } /* Now we can change empty values to "0" */ - for (Parts::iterator i(_imp->parts.begin()), - i_end(_imp->parts.end()) ; i != i_end ; ++i) - if ((*i).number_value().empty() && - (((*i).type() >= vsct_alpha && (*i).type() <= vsct_rc) || - (*i).type() == vsct_patch || - (*i).type() == vsct_trypart)) - (*i).number_value() = "0"; + for (auto & part : _imp->parts) + if (part.number_value().empty() && + ((part.type() >= vsct_alpha && part.type() <= vsct_rc) || + part.type() == vsct_patch || + part.type() == vsct_trypart)) + part.number_value() = "0"; } /* revision */ @@ -523,12 +522,11 @@ VersionSpec::hash() const do { bool first(true); - for (std::vector<VersionSpecComponent>::const_iterator r(_imp->parts.begin()), r_end(_imp->parts.end()) ; - r != r_end ; ++r) + for (const auto & part : _imp->parts) { - if ((*r).number_value() == "0" && (*r).type() == vsct_revision) + if (part.number_value() == "0" && part.type() == vsct_revision) continue; - if ((*r).type() == vsct_ignore) + if (part.type() == vsct_ignore) continue; std::size_t hh(result & h_mask); @@ -536,10 +534,10 @@ VersionSpec::hash() const result ^= (hh >> h_shift); std::string r_v; - if ((*r).type() == vsct_floatlike) - r_v = strip_trailing((*r).number_value(), "0"); + if (part.type() == vsct_floatlike) + r_v = strip_trailing(part.number_value(), "0"); else - r_v = (*r).number_value(); + r_v = part.number_value(); size_t x(0); int zeroes(0); @@ -554,7 +552,7 @@ VersionSpec::hash() const } first = false; - result ^= (static_cast<std::size_t>((*r).type()) + (x << 3) + (zeroes << 12)); + result ^= (static_cast<std::size_t>(part.type()) + (x << 3) + (zeroes << 12)); } } while (false); diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc index e8d18f133..5ec79cc2a 100644 --- a/src/clients/cave/cmd_display_resolution.cc +++ b/src/clients/cave/cmd_display_resolution.cc @@ -391,13 +391,11 @@ namespace } cout << fuc(fs_explanation_constraints_header()); - for (auto c(reasons_for_constraints.begin()), c_end(reasons_for_constraints.end()) ; - c != c_end ; ++c) + for (auto & reasons_for_constraint : reasons_for_constraints) { - cout << fuc(fs_explanation_constraint(), fv<'c'>(c->first)); - for (auto r(c->second.begin()), r_end(c->second.end()) ; - r != r_end ; ++r) - cout << fuc(fs_explanation_constraint_reason(), fv<'r'>(*r)); + cout << fuc(fs_explanation_constraint(), fv<'c'>(reasons_for_constraint.first)); + for (const auto & r : reasons_for_constraint.second) + cout << fuc(fs_explanation_constraint_reason(), fv<'r'>(r)); } } @@ -744,16 +742,14 @@ namespace reasons.insert(r.first); } - for (std::set<std::string>::const_iterator r(changes_reasons.begin()), r_end(changes_reasons.end()) ; - r != r_end ; ++r) + for (const auto & changes_reason : changes_reasons) { - special_reasons.erase(*r); - reasons.erase(*r); + special_reasons.erase(changes_reason); + reasons.erase(changes_reason); } - for (std::set<std::string>::const_iterator r(special_reasons.begin()), r_end(special_reasons.end()) ; - r != r_end ; ++r) - reasons.erase(*r); + for (const auto & special_reason : special_reasons) + reasons.erase(special_reason); if (reasons.empty() && special_reasons.empty() && changes_reasons.empty()) return; @@ -765,9 +761,8 @@ namespace if (! changes_reasons.empty()) { cout << fuc(fs_changes_reasons_start()); - for (std::set<std::string>::const_iterator r(changes_reasons.begin()), r_end(changes_reasons.end()) ; - r != r_end ; ++r) - cout << fuc(fs_reason_changes(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(*r)); + for (const auto & changes_reason : changes_reasons) + cout << fuc(fs_reason_changes(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(changes_reason)); cout << fuc(fs_changes_reasons_end()); } @@ -775,13 +770,11 @@ namespace cout << fuc(fs_reasons()); n_shown = 0; - for (std::set<std::string>::const_iterator r(special_reasons.begin()), r_end(special_reasons.end()) ; - r != r_end ; ++r) - cout << fuc(fs_reason_special(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(*r)); + for (const auto & special_reason : special_reasons) + cout << fuc(fs_reason_special(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(special_reason)); int n_remaining(reasons.size()); - for (std::set<std::string>::const_iterator r(reasons.begin()), r_end(reasons.end()) ; - r != r_end ; ++r) + for (const auto & reason : reasons) { if (n_shown >= 3 && n_remaining > 1) { @@ -790,7 +783,7 @@ namespace } --n_remaining; - cout << fuc(fs_reason_normal(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(*r)); + cout << fuc(fs_reason_normal(), fv<'c'>(++n_shown != 1 ? ", " : ""), fv<'r'>(reason)); } cout << fuc(fs_reasons_end()); @@ -1381,17 +1374,16 @@ namespace (*c)->reason()->accept_returning<std::pair<std::string, Tribool> >(g).first); } - for (auto c(duplicates.begin()), c_end(duplicates.end()) ; - c != c_end ; ++c) + for (auto & duplicate : duplicates) { - auto constraint(c->second.first); + auto constraint(duplicate.second.first); ReasonNameGetter g(false, true); std::string s(constraint_as_string(*constraint) + " from " + constraint->reason()->accept_returning<std::pair<std::string, Tribool> >(g).first); - if (c->second.second.size() > 1) - s.append(" (and " + stringify(c->second.second.size() - 1) + " more)"); + if (duplicate.second.second.size() > 1) + s.append(" (and " + stringify(duplicate.second.second.size() - 1) + " more)"); cout << fuc(fs_unable_unsuitable_did_not_meet(), fv<'s'>(s)); if (constraint->spec().if_package() && constraint->spec().if_package()->additional_requirements_ptr() && @@ -1420,21 +1412,19 @@ namespace { Context context("When displaying choices to explain:"); - for (ChoicesToExplain::const_iterator p(choices_to_explain.begin()), p_end(choices_to_explain.end()) ; - p != p_end ; ++p) + for (const auto & p : choices_to_explain) { - cout << fuc(fs_choice_to_explain_prefix(), fv<'s'>(p->first)); + cout << fuc(fs_choice_to_explain_prefix(), fv<'s'>(p.first)); - for (ChoiceValuesToExplain::const_iterator v(p->second.begin()), v_end(p->second.end()) ; - v != v_end ; ++v) + for (const auto & v : p.second) { bool all_same(true); const std::shared_ptr<const ChoiceValue> first_choice_value( - (*v->second->begin())->choices_key()->parse_value()->find_by_name_with_prefix(v->first)); + (*v.second->begin())->choices_key()->parse_value()->find_by_name_with_prefix(v.first)); std::string description(first_choice_value->description()); - for (PackageIDSequence::ConstIterator w(next(v->second->begin())), w_end(v->second->end()) ; + for (PackageIDSequence::ConstIterator w(next(v.second->begin())), w_end(v.second->end()) ; w != w_end ; ++w) - if ((*w)->choices_key()->parse_value()->find_by_name_with_prefix(v->first)->description() != description) + if ((*w)->choices_key()->parse_value()->find_by_name_with_prefix(v.first)->description() != description) { all_same = false; break; @@ -1445,11 +1435,11 @@ namespace else { cout << fuc(fs_choice_to_explain_not_all_same(), fv<'s'>(stringify(first_choice_value->unprefixed_name()))); - for (PackageIDSequence::ConstIterator w(v->second->begin()), w_end(v->second->end()) ; + for (PackageIDSequence::ConstIterator w(v.second->begin()), w_end(v.second->end()) ; w != w_end ; ++w) { const std::shared_ptr<const ChoiceValue> value( - (*w)->choices_key()->parse_value()->find_by_name_with_prefix(v->first)); + (*w)->choices_key()->parse_value()->find_by_name_with_prefix(v.first)); cout << fuc(fs_choice_to_explain_one(), fv<'s'>((*w)->canonical_form(idcf_no_version)), fv<'d'>(value->description())); } } diff --git a/src/clients/cave/cmd_dump_cave_formats_conf.cc b/src/clients/cave/cmd_dump_cave_formats_conf.cc index 4f8761bcf..c9bc557af 100644 --- a/src/clients/cave/cmd_dump_cave_formats_conf.cc +++ b/src/clients/cave/cmd_dump_cave_formats_conf.cc @@ -219,13 +219,12 @@ DumpCaveFormatsConfCommand::run( get_formats.collect(); std::string current_section; - for (auto i(get_formats.storers.begin()), i_end(get_formats.storers.end()) ; - i != i_end ; ++i) + for (auto & storer : get_formats.storers) { - std::string::size_type p(i->first.find("/")); + std::string::size_type p(storer.first.find("/")); if (std::string::npos == p) - throw InternalError(PALUDIS_HERE, "weird key " + i->first); - std::string section(i->first.substr(0, p)), key(i->first.substr(p + 1)); + throw InternalError(PALUDIS_HERE, "weird key " + storer.first); + std::string section(storer.first.substr(0, p)), key(storer.first.substr(p + 1)); if (current_section != section) { @@ -234,9 +233,9 @@ DumpCaveFormatsConfCommand::run( } cout << key << " = "; - if (0 == i->second.value.compare(0, 1, " ")) + if (0 == storer.second.value.compare(0, 1, " ")) cout << "\\"; - cout << i->second.value << endl; + cout << storer.second.value << endl; } return EXIT_SUCCESS; diff --git a/src/clients/cave/cmd_find_candidates.cc b/src/clients/cave/cmd_find_candidates.cc index 1e278d461..f7b1dd39c 100644 --- a/src/clients/cave/cmd_find_candidates.cc +++ b/src/clients/cave/cmd_find_candidates.cc @@ -175,8 +175,7 @@ FindCandidatesCommand::run_hosted( SearchExtrasHandle::get_instance()->cleanup_db_function(db); - for (auto s(specs.begin()), s_end(specs.end()) ; - s != s_end ; ++s) + for (auto & spec : specs) { step("Checking indexed candidates"); @@ -190,10 +189,9 @@ FindCandidatesCommand::run_hosted( { bool ok(false); - for (auto m(matches.begin()), m_end(matches.end()) ; - m != m_end ; ++m) - if (match_package(*env, *m, *(*env)[selection::RequireExactlyOne(generator::Matches( - parse_user_package_dep_spec(*s, env.get(), { }), nullptr, { }))]->begin(), nullptr, { })) + for (auto & matche : matches) + if (match_package(*env, matche, *(*env)[selection::RequireExactlyOne(generator::Matches( + parse_user_package_dep_spec(spec, env.get(), { }), nullptr, { }))]->begin(), nullptr, { })) { ok = true; break; @@ -203,7 +201,7 @@ FindCandidatesCommand::run_hosted( continue; } - yield(parse_user_package_dep_spec(*s, env.get(), { })); + yield(parse_user_package_dep_spec(spec, env.get(), { })); } } else if (! search_options.a_matching.specified()) @@ -218,10 +216,9 @@ FindCandidatesCommand::run_hosted( step("Searching categories"); CategoryNames category_names; - for (RepositoryNames::const_iterator r(repository_names.begin()), r_end(repository_names.end()) ; - r != r_end ; ++r) + for (const auto & repository_name : repository_names) { - const std::shared_ptr<const Repository> repo(env->fetch_repository(*r)); + const std::shared_ptr<const Repository> repo(env->fetch_repository(repository_name)); const std::shared_ptr<const CategoryNamePartSet> cats(repo->category_names({ })); std::copy(cats->begin(), cats->end(), std::inserter(category_names, category_names.end())); } @@ -229,22 +226,19 @@ FindCandidatesCommand::run_hosted( step("Searching packages"); QualifiedPackageNames package_names; - for (RepositoryNames::const_iterator r(repository_names.begin()), r_end(repository_names.end()) ; - r != r_end ; ++r) + for (const auto & repository_name : repository_names) { - const std::shared_ptr<const Repository> repo(env->fetch_repository(*r)); - for (CategoryNames::const_iterator c(category_names.begin()), c_end(category_names.end()) ; - c != c_end ; ++c) + const std::shared_ptr<const Repository> repo(env->fetch_repository(repository_name)); + for (const auto & category_name : category_names) { - const std::shared_ptr<const QualifiedPackageNameSet> qpns(repo->package_names(*c, { })); + const std::shared_ptr<const QualifiedPackageNameSet> qpns(repo->package_names(category_name, { })); std::copy(qpns->begin(), qpns->end(), std::inserter(package_names, package_names.end())); } } step("Searching versions"); - for (QualifiedPackageNames::const_iterator q(package_names.begin()), q_end(package_names.end()) ; - q != q_end ; ++q) + for (const auto & package_name : package_names) { try { @@ -252,12 +246,12 @@ FindCandidatesCommand::run_hosted( { if (search_options.a_visible.specified()) { - const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q) | filter::NotMasked())]); + const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(package_name) | filter::NotMasked())]); check_candidates(yield, step, ids); } else { - const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q))]); + const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(package_name))]); check_candidates(yield, step, ids); } } @@ -265,19 +259,19 @@ FindCandidatesCommand::run_hosted( { std::shared_ptr<const PackageIDSequence> ids; - ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]); + ids = ((*env)[selection::BestVersionOnly(generator::Package(package_name) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]); if (search_options.a_visible.specified()) { if (ids->empty()) - ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::NotMasked())]); + ids = ((*env)[selection::BestVersionOnly(generator::Package(package_name) | filter::NotMasked())]); } else { if (ids->empty()) - ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>())]); + ids = ((*env)[selection::BestVersionOnly(generator::Package(package_name) | filter::SupportsAction<InstallAction>())]); if (ids->empty()) - ids = ((*env)[selection::BestVersionOnly(generator::Package(*q))]); + ids = ((*env)[selection::BestVersionOnly(generator::Package(package_name))]); } check_candidates(yield, step, ids); @@ -289,7 +283,7 @@ FindCandidatesCommand::run_hosted( } catch (const Exception & e) { - std::cerr << "When processing '" << *q << "' got exception '" << e.message() << "' (" << e.what() << ")" << std::endl; + std::cerr << "When processing '" << package_name << "' got exception '" << e.message() << "' (" << e.what() << ")" << std::endl; retcode |= 1; } } diff --git a/src/clients/cave/cmd_fix_cache.cc b/src/clients/cave/cmd_fix_cache.cc index 16a745308..01d580b3c 100644 --- a/src/clients/cave/cmd_fix_cache.cc +++ b/src/clients/cave/cmd_fix_cache.cc @@ -140,11 +140,10 @@ FixCacheCommand::run( r != r_end; ++r) repository_names.insert(r->name()); - for (std::set<RepositoryName>::const_iterator r(repository_names.begin()), r_end(repository_names.end()) ; - r != r_end; ++r) + for (const auto & repository_name : repository_names) { - cout << fuc(fs_fixing(), fv<'s'>(stringify(*r))); - const std::shared_ptr<Repository> repo(env->fetch_repository(*r)); + cout << fuc(fs_fixing(), fv<'s'>(stringify(repository_name))); + const std::shared_ptr<Repository> repo(env->fetch_repository(repository_name)); repo->regenerate_cache(); } diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc index e193b372d..6a722a044 100644 --- a/src/clients/cave/cmd_info.cc +++ b/src/clients/cave/cmd_info.cc @@ -154,11 +154,10 @@ namespace { cout << fuc(fs_metadata_subsection(), fv<'i'>(std::string(indent, ' ')), fv<'s'>(k.human_name())); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(k.begin_metadata(), k.end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - s(keys.begin()), s_end(keys.end()) ; s != s_end ; ++s) + for (const auto & key : keys) { InfoDisplayer i(env, cmdline, indent + 1); - (*s)->accept(i); + key->accept(i); } } @@ -293,14 +292,13 @@ namespace { cout << fuc(fs_repository_heading(), fv<'s'>(stringify(repo->name()))); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(repo->begin_metadata(), repo->end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k) + for (const auto & key : keys) { - if ((*k)->type() == mkt_internal) + if (key->type() == mkt_internal) continue; InfoDisplayer i(env.get(), cmdline, 1); - (*k)->accept(i); + key->accept(i); } cout << endl; } @@ -311,14 +309,13 @@ namespace { cout << fuc(fs_heading(), fv<'s'>("Environment Information")); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(env->begin_metadata(), env->end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k) + for (const auto & key : keys) { - if ((*k)->type() == mkt_internal) + if (key->type() == mkt_internal) continue; InfoDisplayer i(env.get(), cmdline, 1); - (*k)->accept(i); + key->accept(i); } cout << endl; } @@ -330,14 +327,13 @@ namespace cout << fuc(fs_heading(), fv<'s'>("Package Manager Information")); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(AboutMetadata::get_instance()->begin_metadata(), AboutMetadata::get_instance()->end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k) + for (const auto & key : keys) { - if ((*k)->type() == mkt_internal) + if (key->type() == mkt_internal) continue; InfoDisplayer i(env.get(), cmdline, 1); - (*k)->accept(i); + key->accept(i); } cout << endl; } diff --git a/src/clients/cave/cmd_print_unmanaged_files.cc b/src/clients/cave/cmd_print_unmanaged_files.cc index 1fe8772cd..ce27736e8 100644 --- a/src/clients/cave/cmd_print_unmanaged_files.cc +++ b/src/clients/cave/cmd_print_unmanaged_files.cc @@ -208,9 +208,8 @@ PrintUnmanagedFilesCommand::run(const std::shared_ptr<Environment> & env, std::inserter(unmanaged_files, unmanaged_files.begin()), FSPathComparator()); - for (auto entry(unmanaged_files.begin()), end(unmanaged_files.end()); - entry != end; ++entry) - cout << *entry << endl; + for (const auto & unmanaged_file : unmanaged_files) + cout << unmanaged_file << endl; return EXIT_SUCCESS; } diff --git a/src/clients/cave/cmd_print_unused_distfiles.cc b/src/clients/cave/cmd_print_unused_distfiles.cc index c459938a9..08af2718c 100644 --- a/src/clients/cave/cmd_print_unused_distfiles.cc +++ b/src/clients/cave/cmd_print_unused_distfiles.cc @@ -164,10 +164,9 @@ PrintUnusedDistfilesCommand::run( selections.push_back(selection::AllVersionsUnsorted(generator::InRepository(RepositoryName(*c)))); std::set<std::shared_ptr<const PackageID>, PackageIDComparator> already_done((PackageIDComparator(env.get()))); - for (auto s(selections.begin()), s_end(selections.end()) ; - s != s_end ; ++s) + for (auto & selection : selections) { - auto ids((*env)[*s]); + auto ids((*env)[selection]); for (PackageIDSequence::ConstIterator iter(ids->begin()), end(ids->end()) ; iter != end ; ++iter) @@ -205,9 +204,9 @@ PrintUnusedDistfilesCommand::run( // Iterate through the distdirs and compare their contents with the used distfiles // - for (auto dir(distdirs.begin()), d_end(distdirs.end()) ; dir != d_end ; ++dir) + for (const auto & distdir : distdirs) { - for (FSIterator file(*dir, {fsio_include_dotfiles, fsio_want_regular_files}), f_end ; + for (FSIterator file(distdir, {fsio_include_dotfiles, fsio_want_regular_files}), f_end ; file != f_end ; ++file) { if (used_distfiles.find(file->basename()) == used_distfiles.end()) diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc index 052c449f5..8fb2b6e74 100644 --- a/src/clients/cave/cmd_show.cc +++ b/src/clients/cave/cmd_show.cc @@ -439,13 +439,12 @@ namespace fv<'i'>(std::string(indent, ' '))); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(k.begin_metadata(), k.end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - s(keys.begin()), s_end(keys.end()) ; s != s_end ; ++s) + for (const auto & key : keys) { InfoDisplayer i(env, cmdline, basic_ppos, indent + 1, - ((*s)->type() == mkt_significant), maybe_current_id, maybe_old_id, old_id_is_installed, out); - if (want_key(cmdline, *s, maybe_current_id)) - accept_visitor(i)(**s); + (key->type() == mkt_significant), maybe_current_id, maybe_old_id, old_id_is_installed, out); + if (want_key(cmdline, key, maybe_current_id)) + accept_visitor(i)(*key); } } @@ -1073,12 +1072,11 @@ namespace const std::shared_ptr<const Repository> repo(env->fetch_repository(s)); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(repo->begin_metadata(), repo->end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k) + for (const auto & key : keys) { - InfoDisplayer i(env, cmdline, basic_ppos, 0, ((*k)->type() == mkt_significant), nullptr, nullptr, false, cout); - if (want_key(cmdline, *k, nullptr)) - accept_visitor(i)(**k); + InfoDisplayer i(env, cmdline, basic_ppos, 0, (key->type() == mkt_significant), nullptr, nullptr, false, cout); + if (want_key(cmdline, key, nullptr)) + accept_visitor(i)(*key); } cout << endl; } @@ -1107,13 +1105,12 @@ namespace out << fuc(fs_package_id_heading(), fv<'s'>(stringify(*best)), fv<'t'>(in_sets)); std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(best->begin_metadata(), best->end_metadata()); - for (std::set<std::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator - k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k) + for (const auto & key : keys) { - bool explicit_key(cmdline.a_key.end_args() != std::find(cmdline.a_key.begin_args(), cmdline.a_key.end_args(), (*k)->raw_name())); - InfoDisplayer i(env, cmdline, basic_ppos, 0, ((*k)->type() == mkt_significant) || explicit_key, best, maybe_old_id, old_id_is_installed, out); - if (want_key(cmdline, *k, best)) - accept_visitor(i)(**k); + bool explicit_key(cmdline.a_key.end_args() != std::find(cmdline.a_key.begin_args(), cmdline.a_key.end_args(), key->raw_name())); + InfoDisplayer i(env, cmdline, basic_ppos, 0, (key->type() == mkt_significant) || explicit_key, best, maybe_old_id, old_id_is_installed, out); + if (want_key(cmdline, key, best)) + accept_visitor(i)(*key); } if (best->masked()) @@ -1182,16 +1179,15 @@ namespace if (! best_installable) best_installable = best_not_installed; - for (std::set<RepositoryName>::const_iterator r(repos.begin()), r_end(repos.end()) ; - r != r_end ; ++r) + for (const auto & r : repos) { - header_out << fuc(fs_package_repository(), fv<'s'>(stringify(*r))); + header_out << fuc(fs_package_repository(), fv<'s'>(stringify(r))); std::string slot_name; bool need_space(false); for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ; i != i_end ; ++i) { - if ((*i)->repository_name() != *r) + if ((*i)->repository_name() != r) continue; if (slot_name != slot_as_string(*i)) @@ -1295,10 +1291,10 @@ namespace std::stringstream rest_out; - for (auto r(repos.begin()), r_end(repos.end()) ; r != r_end ; ++r) + for (const auto & repo : repos) { auto r_ids((*env)[selection::AllVersionsGroupedBySlot(generator::Matches( - PartiallyMadePackageDepSpec(s).in_repository(*r), nullptr, { }))]); + PartiallyMadePackageDepSpec(s).in_repository(repo), nullptr, { }))]); if (! r_ids->empty()) do_one_package_with_ids(cmdline, env, basic_ppos, s, r_ids, cout, rest_out); } diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc index 8d8e564b1..2395b0ae5 100644 --- a/src/clients/cave/cmd_sync.cc +++ b/src/clients/cave/cmd_sync.cc @@ -315,10 +315,9 @@ namespace { Executor executor; - for (Repos::const_iterator r(repos.begin()), r_end(repos.end()) ; - r != r_end ; ++r) + for (const auto & repo : repos) { - const std::shared_ptr<SyncExecutive> x(std::make_shared<SyncExecutive>(env, cmdline, &executor, *r)); + const std::shared_ptr<SyncExecutive> x(std::make_shared<SyncExecutive>(env, cmdline, &executor, repo)); executor.add(x); executives.push_back(x); } diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index fe1cb8f51..830cf444c 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -608,25 +608,24 @@ namespace std::cout << "Dumping restarts:" << std::endl << std::endl; - for (std::list<SuggestRestart>::const_iterator r(restarts.begin()), r_end(restarts.end()) ; - r != r_end ; ++r) + for (const auto & restart : restarts) { - std::cout << "* " << r->resolvent() << std::endl; + std::cout << "* " << restart.resolvent() << std::endl; std::cout << " Had decided upon "; - auto c(get_decided_id_or_null(r->previous_decision())); + auto c(get_decided_id_or_null(restart.previous_decision())); if (c) std::cout << *c; else - std::cout << r->previous_decision()->accept_returning<std::string>(KindNameVisitor()); + std::cout << restart.previous_decision()->accept_returning<std::string>(KindNameVisitor()); std::cout << std::endl; - std::cout << " Which did not satisfy " << r->problematic_constraint()->spec() - << ", use existing " << r->problematic_constraint()->use_existing(); - if (r->problematic_constraint()->nothing_is_fine_too()) + std::cout << " Which did not satisfy " << restart.problematic_constraint()->spec() + << ", use existing " << restart.problematic_constraint()->use_existing(); + if (restart.problematic_constraint()->nothing_is_fine_too()) std::cout << ", nothing is fine too"; - std::cout << " " << r->problematic_constraint()->reason()->accept_returning<std::string>(ShortReasonName()); + std::cout << " " << restart.problematic_constraint()->reason()->accept_returning<std::string>(ShortReasonName()); std::cout << std::endl; } |