summaryrefslogtreecommitdiffstats
path: root/Source/cmStateDirectory.cxx
diff options
context:
space:
mode:
authorArtur Ryt <artur.ryt@gmail.com>2019-02-07 21:39:05 (GMT)
committerArtur Ryt <artur.ryt@gmail.com>2019-02-07 21:39:05 (GMT)
commit01b2d6ab7465e7f22fb821876027df86b0c8f363 (patch)
tree7ae313670e3655269ef7f9db6feabdc4bb2aaf25 /Source/cmStateDirectory.cxx
parent15bdbec0176e3aa620bb5bda3631819c5ca18eaf (diff)
downloadCMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.zip
CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.gz
CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.bz2
Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some reverse-iterator loops with range loops. Fixes: #18858
Diffstat (limited to 'Source/cmStateDirectory.cxx')
-rw-r--r--Source/cmStateDirectory.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 6752743..15c8a61 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -8,6 +8,7 @@
#include <iterator>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmState.h"
@@ -40,9 +41,8 @@ void cmStateDirectory::ComputeRelativePathTopSource()
std::string result = snapshots.front().GetDirectory().GetCurrentSource();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentSource = it->GetDirectory().GetCurrentSource();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentSource = snp.GetDirectory().GetCurrentSource();
if (cmSystemTools::IsSubDirectory(result, currentSource)) {
result = currentSource;
}
@@ -66,9 +66,8 @@ void cmStateDirectory::ComputeRelativePathTopBinary()
std::string result = snapshots.front().GetDirectory().GetCurrentBinary();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentBinary = it->GetDirectory().GetCurrentBinary();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentBinary = snp.GetDirectory().GetCurrentBinary();
if (cmSystemTools::IsSubDirectory(result, currentBinary)) {
result = currentBinary;
}