diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
---|---|---|
committer | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
commit | 01b2d6ab7465e7f22fb821876027df86b0c8f363 (patch) | |
tree | 7ae313670e3655269ef7f9db6feabdc4bb2aaf25 /Source/cmFileCommand.cxx | |
parent | 15bdbec0176e3aa620bb5bda3631819c5ca18eaf (diff) | |
download | CMake-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/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2fe0d63..fb3a1bc 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -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) && |