Commit 01b2d6ab authored by Artur Ryt's avatar Artur Ryt

Modernize: Use ranged for-loops when possible

Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
parent 15bdbec0
......@@ -44,10 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
// to create the file before the super class is called
{
cmGeneratedFileStream ofs(manifestFile.c_str());
for (std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i) {
for (std::string const& file : files) {
// remove the temp dir and replace with /usr
ofs << (*i).substr(tempdir.size()) << "\n";
ofs << file.substr(tempdir.size()) << "\n";
}
ofs << manifest << "\n";
}
......
......@@ -66,21 +66,17 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.StartElement("choices-outline");
// Emit the outline for the groups
std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
for (groupIt = this->ComponentGroups.begin();
groupIt != this->ComponentGroups.end(); ++groupIt) {
if (groupIt->second.ParentGroup == nullptr) {
CreateChoiceOutline(groupIt->second, xout);
for (auto const& group : this->ComponentGroups) {
if (group.second.ParentGroup == nullptr) {
CreateChoiceOutline(group.second, xout);
}
}
// Emit the outline for the non-grouped components
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
if (!compIt->second.Group) {
for (auto const& comp : this->Components) {
if (!comp.second.Group) {
xout.StartElement("line");
xout.Attribute("choice", compIt->first + "Choice");
xout.Attribute("choice", comp.first + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
......@@ -94,13 +90,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.EndElement(); // choices-outline>
// Create the actual choices
for (groupIt = this->ComponentGroups.begin();
groupIt != this->ComponentGroups.end(); ++groupIt) {
CreateChoice(groupIt->second, xout);
for (auto const& group : this->ComponentGroups) {
CreateChoice(group.second, xout);
}
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
CreateChoice(compIt->second, xout);
for (auto const& comp : this->Components) {
CreateChoice(comp.second, xout);
}
if (!this->PostFlightComponent.Name.empty()) {
......@@ -119,17 +113,13 @@ void cmCPackPKGGenerator::CreateChoiceOutline(
{
xout.StartElement("line");
xout.Attribute("choice", group.Name + "Choice");
std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
++groupIt) {
CreateChoiceOutline(**groupIt, xout);
for (cmCPackComponentGroup* subgroup : group.Subgroups) {
CreateChoiceOutline(*subgroup, xout);
}
std::vector<cmCPackComponent*>::const_iterator compIt;
for (compIt = group.Components.begin(); compIt != group.Components.end();
++compIt) {
for (cmCPackComponent* comp : group.Components) {
xout.StartElement("line");
xout.Attribute("choice", (*compIt)->Name + "Choice");
xout.Attribute("choice", comp->Name + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
......@@ -238,11 +228,9 @@ void cmCPackPKGGenerator::AddDependencyAttributes(
}
visited.insert(&component);
std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.Dependencies.begin();
dependIt != component.Dependencies.end(); ++dependIt) {
out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
AddDependencyAttributes(**dependIt, visited, out);
for (cmCPackComponent* depend : component.Dependencies) {
out << " && choices['" << depend->Name << "Choice'].selected";
AddDependencyAttributes(*depend, visited, out);
}
}
......@@ -255,11 +243,9 @@ void cmCPackPKGGenerator::AddReverseDependencyAttributes(
}
visited.insert(&component);
std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.ReverseDependencies.begin();
dependIt != component.ReverseDependencies.end(); ++dependIt) {
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
AddReverseDependencyAttributes(**dependIt, visited, out);
for (cmCPackComponent* depend : component.ReverseDependencies) {
out << " || choices['" << depend->Name << "Choice'].selected";
AddReverseDependencyAttributes(*depend, visited, out);
}
}
......
......@@ -3,6 +3,7 @@
#include "cmCTestMultiProcessHandler.h"
#include "cmAffinity.h"
#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestRunTest.h"
#include "cmCTestTestHandler.h"
......@@ -651,9 +652,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// Reverse iterate over the different dependency levels (deepest first).
// Sort tests within each level by COST and append them to the cost list.
for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
i != priorityStack.rend(); ++i) {
TestSet const& currentSet = *i;
for (TestSet const& currentSet : cmReverseRange(priorityStack)) {
TestComparator comp(this);
TestList sortedCopy;
......
......@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestP4.h"
#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
......@@ -425,12 +426,11 @@ bool cmCTestP4::LoadRevisions()
// p4 describe -s ...@1111111,2222222
std::vector<char const*> p4_describe;
for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
i != ChangeLists.rend(); ++i) {
for (std::string const& i : cmReverseRange(ChangeLists)) {
SetP4Options(p4_describe);
p4_describe.push_back("describe");
p4_describe.push_back("-s");
p4_describe.push_back(i->c_str());
p4_describe.push_back(i.c_str());
p4_describe.push_back(nullptr);
DescribeParser outDescribe(this, "p4_describe-out> ");
......
......@@ -19,9 +19,8 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(
std::vector<std::string> const& messages, const char* title)
{
// Append all messages into on big string
std::vector<std::string>::const_iterator it;
for (it = messages.begin(); it != messages.end(); it++) {
this->Messages += (*it);
for (std::string const& message : messages) {
this->Messages += message;
// Add one blank line after each message
this->Messages += "\n\n";
}
......
......@@ -107,10 +107,9 @@ void cmCursesMainForm::InitializeUI()
// Count non-internal and non-static entries
int count = 0;
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it) {
for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
++count;
......@@ -130,11 +129,9 @@ void cmCursesMainForm::InitializeUI()
// Create the composites.
// First add entries which are new
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it) {
std::string key = *it;
for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
......@@ -148,11 +145,9 @@ void cmCursesMainForm::InitializeUI()
}
// then add entries which are old
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it) {
std::string key = *it;
for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
this->CMakeInstance->GetState()->GetCacheEntryType(*it);
this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
......
......@@ -95,33 +95,32 @@ void StartCompilerSetup::setGenerators(
QStringList generator_list;
std::vector<cmake::GeneratorInfo>::const_iterator it;
for (it = gens.begin(); it != gens.end(); ++it) {
generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
for (cmake::GeneratorInfo const& gen : gens) {
generator_list.append(QString::fromLocal8Bit(gen.name.c_str()));
if (it->supportsPlatform) {
if (gen.supportsPlatform) {
this->GeneratorsSupportingPlatform.append(
QString::fromLocal8Bit(it->name.c_str()));
QString::fromLocal8Bit(gen.name.c_str()));
this
->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] =
QString::fromLocal8Bit(it->defaultPlatform.c_str());
->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] =
QString::fromLocal8Bit(gen.defaultPlatform.c_str());
std::vector<std::string>::const_iterator platformIt =
it->supportedPlatforms.cbegin();
while (platformIt != it->supportedPlatforms.cend()) {
gen.supportedPlatforms.cbegin();
while (platformIt != gen.supportedPlatforms.cend()) {
this->GeneratorSupportedPlatforms.insert(
QString::fromLocal8Bit(it->name.c_str()),
QString::fromLocal8Bit(gen.name.c_str()),
QString::fromLocal8Bit((*platformIt).c_str()));
platformIt++;
}
}
if (it->supportsToolset) {
if (gen.supportsToolset) {
this->GeneratorsSupportingToolset.append(
QString::fromLocal8Bit(it->name.c_str()));
QString::fromLocal8Bit(gen.name.c_str()));
}
}
......
......@@ -48,9 +48,8 @@ QCMake::QCMake(QObject* p)
this->CMakeInstance->GetRegisteredGenerators(
generators, /*includeNamesWithPlatform=*/false);
std::vector<cmake::GeneratorInfo>::const_iterator it;
for (it = generators.begin(); it != generators.end(); ++it) {
this->AvailableGenerators.push_back(*it);
for (cmake::GeneratorInfo const& gen : generators) {
this->AvailableGenerators.push_back(gen);
}
}
......@@ -234,24 +233,23 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
it != cacheKeys.end(); ++it) {
cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it);
for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) {
continue;
}
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(it->c_str());
prop.Key = QString::fromLocal8Bit(key.c_str());
int idx = props.indexOf(prop);
if (idx == -1) {
toremove.append(QString::fromLocal8Bit(it->c_str()));
toremove.append(QString::fromLocal8Bit(key.c_str()));
} else {
prop = props[idx];
if (prop.Value.type() == QVariant::Bool) {
state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
} else {
state->SetCacheEntryValue(*it,
state->SetCacheEntryValue(key,
prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
......@@ -297,22 +295,21 @@ QCMakePropertyList QCMake::properties() const
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
i != cacheKeys.end(); ++i) {
cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i);
for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
}
const char* cachedValue = state->GetCacheEntryValue(*i);
const char* cachedValue = state->GetCacheEntryValue(key);
QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(i->c_str());
prop.Key = QString::fromLocal8Bit(key.c_str());
prop.Help =
QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING"));
QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
if (t == cmStateEnums::BOOL) {
prop.Type = QCMakeProperty::BOOL;
prop.Value = cmSystemTools::IsOn(cachedValue);
......@@ -323,7 +320,7 @@ QCMakePropertyList QCMake::properties() const
} else if (t == cmStateEnums::STRING) {
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
state->GetCacheEntryProperty(*i, "STRINGS");
state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProperty) {
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
}
......
......@@ -4,6 +4,7 @@
#include <sstream>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmTarget.h"
......@@ -27,10 +28,10 @@ bool cmAddDependenciesCommand::InitialPass(
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
std::vector<std::string>::const_iterator s = args.begin();
++s; // skip over target_name
for (; s != args.end(); ++s) {
target->AddUtility(*s, this->Makefile);
// skip over target_name
for (std::string const& arg : cmMakeRange(args).advance(1)) {
target->AddUtility(arg, this->Makefile);
}
} else {
std::ostringstream e;
......
......@@ -5,6 +5,7 @@
#include <sstream>
#include <string.h>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
......@@ -26,15 +27,13 @@ bool cmAddSubDirectoryCommand::InitialPass(
bool excludeFromAll = false;
// process the rest of the arguments looking for optional args
std::vector<std::string>::const_iterator i = args.begin();
++i;
for (; i != args.end(); ++i) {
if (*i == "EXCLUDE_FROM_ALL") {
for (std::string const& arg : cmMakeRange(args).advance(1)) {
if (arg == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
}
if (binArg.empty()) {
binArg = *i;
binArg = arg;
} else {
this->SetError("called with incorrect number of arguments");
return false;
......
......@@ -683,26 +683,24 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
}
// Next, try the various source extensions
for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
ext != sourceExts.end(); ++ext) {
for (std::string const& ext : sourceExts) {
hname = pathname;
hname += ".";
hname += *ext;
hname += ext;
if (cmSystemTools::FileExists(hname)) {
sf->SourceExtension = *ext;
sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
}
// Finally, try the various header extensions
for (std::vector<std::string>::const_iterator ext = headerExts.begin();
ext != headerExts.end(); ++ext) {
for (std::string const& ext : headerExts) {
hname = pathname;
hname += ".";
hname += *ext;
hname += ext;
if (cmSystemTools::FileExists(hname)) {
sf->SourceExtension = *ext;
sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
......@@ -711,13 +709,11 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
std::ostringstream e;
e << "Cannot find source file \"" << pathname << "\"";
e << "\n\nTried extensions";
for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
ext != sourceExts.end(); ++ext) {
e << " ." << *ext;
for (std::string const& ext : sourceExts) {
e << " ." << ext;
}
for (std::vector<std::string>::const_iterator ext = headerExts.begin();
ext != headerExts.end(); ++ext) {
e << " ." << *ext;
for (std::string const& ext : headerExts) {
e << " ." << ext;
}
cmSystemTools::Error(e.str());
}
......
......@@ -256,11 +256,7 @@ cmComputeLinkDepends::Compute()
// Iterate in reverse order so we can keep only the last occurrence
// of a shared library.
std::set<int> emmitted;
for (std::vector<int>::const_reverse_iterator
li = this->FinalLinkOrder.rbegin(),
le = this->FinalLinkOrder.rend();
li != le; ++li) {
int i = *li;
for (int i : cmReverseRange(this->FinalLinkOrder)) {
LinkEntry const& e = this->EntryList[i];
cmGeneratorTarget const* t = e.Target;
// Entries that we know the linker will re-use do not need to be repeated.
......@@ -586,11 +582,10 @@ void cmComputeLinkDepends::InferDependencies()
}
// Intersect the sets for this item.
DependSetList::const_iterator i = sets->begin();
DependSet common = *i;
for (++i; i != sets->end(); ++i) {
DependSet common = sets->front();
for (DependSet const& i : cmMakeRange(*sets).advance(1)) {
DependSet intersection;
std::set_intersection(common.begin(), common.end(), i->begin(), i->end(),
std::set_intersection(common.begin(), common.end(), i.begin(), i.end(),
std::inserter(intersection, intersection.begin()));
common = intersection;
}
......@@ -708,9 +703,8 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
// Run in reverse order so the topological order will preserve the
// original order where there are no constraints.
EdgeList const& nl = this->CCG->GetComponentGraphEdges(c);
for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
++ni) {
this->VisitComponent(*ni);
for (cmGraphEdge const& edge : cmReverseRange(nl)) {
this->VisitComponent(edge);
}
// Assign an ordering id to this component.
......
......@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeTargetDepends.h"
#include "cmAlgorithms.h"
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
......@@ -549,10 +550,9 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
int head = -1;
std::set<int> emitted;
NodeList const& nl = components[c];
for (NodeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
++ni) {
for (int ni : cmReverseRange(nl)) {
std::set<int> visited;
if (!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) {
if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) {
// Cycle in add_dependencies within component!
this->ComplainAboutBadComponent(ccg, c, true);
return false;
......
......@@ -589,10 +589,9 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
std::vector<std::string>::const_iterator end =
cmRemoveDuplicates(allIncludeDirs);
for (std::vector<std::string>::const_iterator i = allIncludeDirs.begin();
i != end; ++i) {
for (std::string const& str : cmMakeRange(allIncludeDirs.cbegin(), end)) {
xml.StartElement("Add");
xml.Attribute("directory", *i);
xml.Attribute("directory", str);
xml.EndElement();
}
......
......@@ -4,6 +4,7 @@
#include <stddef.h>
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
......@@ -40,18 +41,17 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddIncludeDirectories(outputDirectories);
}
for (std::vector<std::string>::const_iterator i = (args.begin() + 1);
i != args.end(); i++) {
cmSourceFile* curr = this->Makefile->GetSource(*i);
for (std::string const& arg : cmMakeRange(args).advance(1)) {
cmSourceFile* curr = this->Makefile->GetSource(arg);
// if we should use the source GUI
// to generate .cxx and .h files
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
std::string outName = outputDirectory;
outName += "/";
outName += cmSystemTools::GetFilenameWithoutExtension(*i);
outName += cmSystemTools::GetFilenameWithoutExtension(arg);
std::string hname = outName;
hname += ".h";
std::string origname = cdir + "/" + *i;
std::string origname = cdir + "/" + arg;
// add starting depends
std::vector<std::string> depends;
depends.push_back(origname);
......
......@@ -947,16 +947,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
// File command has at least one argument
assert(args.size() > 1);
std::vector<std::string>::const_iterator i = args.begin();
i++; // Get rid of subcommand
std::string expr;
for (; i != args.end(); ++i) {
const std::string* cdir = &(*i);
if (!cmsys::SystemTools::FileIsFullPath(*i)) {
for (std::string const& arg :
cmMakeRange(args).advance(1)) // Get rid of subcommand
{
const std::string* cdir = &arg;
if (!cmsys::SystemTools::FileIsFullPath(arg)) {
expr = this->Makefile->GetCurrentSourceDirectory();
expr += "/" + *i;
expr += "/" + arg;
cdir = &expr;
}
if (!this->Makefile->CanIWriteThisFile(*cdir)) {
......@@ -981,15 +979,13 @@ bool cmFileCommand::HandleTouchCommand(std::vector<std::string> const& args,
// File command has at least one argument
assert(args.size() > 1);
std::vector<std::string>::const_iterator i = args.begin();
i++; // Get rid of subcommand
for (; i != args.end(); ++i) {
std::string tfile = *i;
for (std::string const& arg :
cmMakeRange(args).advance(1)) // Get rid of subcommand
{
std::string tfile = arg;
if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
tfile = this->Makefile->GetCurrentSourceDirectory();
tfile += "/" + *i;
tfile += "/" + arg;
}
if (!this->Makefile->CanIWriteThisFile(tfile)) {
std::string e =
......@@ -2481,14 +2477,14 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
{
std::string message;
std::vector<std::string>::const_iterator i = args.begin();
i++; // Get rid of subcommand
for (; i != args.end(); ++i) {
std::string fileName = *i;
for (std::string const& arg :
cmMakeRange(args).advance(1)) // Get rid of subcommand
{
std::string fileName = arg;
if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
fileName = this->Makefile->GetCurrentSourceDirectory();
fileName += "/" + *i;
fileName += "/" + arg;
}
if (cmSystemTools::FileIsDirectory(fileName) &&
......
......@@ -4,7 +4,6 @@
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <stddef.h>
......@@ -205,11 +204,9 @@ void cmFindBase::FillPackageRootPath()
cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot];
// Add the PACKAGE_ROOT_PATH from each enclosing find_package call.
for (std::deque<std::vector<std::string>>::const_reverse_iterator pkgPaths =
this->Makefile->FindPackageRootPathStack.rbegin();
pkgPaths != this->Makefile->FindPackageRootPathStack.rend();
++pkgPaths) {
paths.AddPrefixPaths(*pkgPaths);
for (std::vector<std::string> const& pkgPaths :
cmReverseRange(this->Makefile->FindPackageRootPathStack)) {
paths.AddPrefixPaths(pkgPaths);
}
paths.AddSuffixes(this->SearchPathSuffixes);
......
......@@ -827,10 +827,10 @@ bool cmFindPackageCommand::HandlePackageMode()
<< " requested version \"" << this->Version << "\".\n"
<< "The following configuration files were considered but not "
"accepted:\n";
for (std::vector<ConfigFileInfo>::const_iterator i =
this->ConsideredConfigs.begin();
i != duplicate_end; ++i) {
e << " " << i->filename << ", version: " << i->version << "\n";
for (ConfigFileInfo const& info :
cmMakeRange(this->ConsideredConfigs.cbegin(), duplicate_end)) {
e << " " << info.filename << ", version: " << info.version << "\n";
}
} else {
std::string requestedVersionString;
......
......@@ -48,12 +48,10 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
if (mf.GetDefinition(this->Args[0])) {
oldDef = mf.GetDefinition(this->Args[0]);
}
std::vector<std::string>::const_iterator j = this->Args.begin();
++j;
for (; j != this->Args.end(); ++j) {
for (std::string const& arg : cmMakeRange(this->Args).advance(1)) {
// set the variable to the loop value
mf.AddDefinition(this->Args[0], j->c_str());
mf.AddDefinition(this->Args[0], arg.c_str());
// Invoke all the functions that were collected in the block.
cmExecutionStatus status;
for (cmListFileFunction const& func : this->Functions) {
......
......@@ -34,20 +34,16 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
std::vector<cmGeneratorExpressionEvaluator*>>::const_iterator pend =
this->ParamChildren.end();
for (; pit != pend; ++pit) {
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
pit->end();
for (; it != end; ++it) {