瀏覽代碼

Prefer front/back/data over dereferencing begin/rbegin iter

Changed for sequenced containers: vector, list, string and array
Artur Ryt 6 年之前
父節點
當前提交
f3534386b5

+ 1 - 1
Source/CPack/OSXScriptLauncher.cxx

@@ -73,7 +73,7 @@ int main(int argc, char* argv[])
   args.push_back(nullptr);
   args.push_back(nullptr);
 
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*args.begin());
+  cmsysProcess_SetCommand(cp, args.data());
   cmsysProcess_SetWorkingDirectory(cp, scriptDirectory.c_str());
   cmsysProcess_SetWorkingDirectory(cp, scriptDirectory.c_str());
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetTimeout(cp, 0);
   cmsysProcess_SetTimeout(cp, 0);

+ 2 - 2
Source/CTest/cmCTestBuildHandler.cxx

@@ -800,7 +800,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
 
 
   // Now create process object
   // Now create process object
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetTimeout(cp, timeout);
   cmsysProcess_SetTimeout(cp, timeout);
@@ -978,7 +978,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
       this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
       this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
                                          queue->begin(), it);
                                          queue->begin(), it);
       this->CurrentProcessingLine.push_back(0);
       this->CurrentProcessingLine.push_back(0);
-      const char* line = &*this->CurrentProcessingLine.begin();
+      const char* line = this->CurrentProcessingLine.data();
 
 
       // Process the line
       // Process the line
       int lineType = this->ProcessSingleLine(line);
       int lineType = this->ProcessSingleLine(line);

+ 1 - 1
Source/CTest/cmCTestCoverageHandler.cxx

@@ -72,7 +72,7 @@ public:
       args.push_back(cl.c_str());
       args.push_back(cl.c_str());
     }
     }
     args.push_back(nullptr); // null terminate
     args.push_back(nullptr); // null terminate
-    cmsysProcess_SetCommand(this->Process, &*args.begin());
+    cmsysProcess_SetCommand(this->Process, args.data());
     if (!this->WorkingDirectory.empty()) {
     if (!this->WorkingDirectory.empty()) {
       cmsysProcess_SetWorkingDirectory(this->Process,
       cmsysProcess_SetWorkingDirectory(this->Process,
                                        this->WorkingDirectory.c_str());
                                        this->WorkingDirectory.c_str());

+ 1 - 1
Source/CTest/cmCTestScriptHandler.cxx

@@ -199,7 +199,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
 
 
   // Now create process object
   // Now create process object
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   // cmsysProcess_SetWorkingDirectory(cp, dir);
   // cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   // cmsysProcess_SetTimeout(cp, timeout);
   // cmsysProcess_SetTimeout(cp, timeout);

+ 10 - 11
Source/CTest/cmCTestSubmitHandler.cxx

@@ -343,7 +343,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
       if (!chunk.empty()) {
       if (!chunk.empty()) {
         cmCTestOptionalLog(this->CTest, DEBUG,
         cmCTestOptionalLog(this->CTest, DEBUG,
                            "CURL output: ["
                            "CURL output: ["
-                             << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                             << cmCTestLogWrite(chunk.data(), chunk.size())
                              << "]" << std::endl,
                              << "]" << std::endl,
                            this->Quiet);
                            this->Quiet);
         this->ParseResponse(chunk);
         this->ParseResponse(chunk);
@@ -352,7 +352,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
         cmCTestOptionalLog(
         cmCTestOptionalLog(
           this->CTest, DEBUG,
           this->CTest, DEBUG,
           "CURL debug output: ["
           "CURL debug output: ["
-            << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+            << cmCTestLogWrite(chunkDebug.data(), chunkDebug.size()) << "]"
             << std::endl,
             << std::endl,
           this->Quiet);
           this->Quiet);
       }
       }
@@ -404,12 +404,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
           res = ::curl_easy_perform(curl);
           res = ::curl_easy_perform(curl);
 
 
           if (!chunk.empty()) {
           if (!chunk.empty()) {
-            cmCTestOptionalLog(
-              this->CTest, DEBUG,
-              "CURL output: ["
-                << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-                << std::endl,
-              this->Quiet);
+            cmCTestOptionalLog(this->CTest, DEBUG,
+                               "CURL output: ["
+                                 << cmCTestLogWrite(chunk.data(), chunk.size())
+                                 << "]" << std::endl,
+                               this->Quiet);
             this->ParseResponse(chunk);
             this->ParseResponse(chunk);
           }
           }
 
 
@@ -433,11 +432,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
         // avoid deref of begin for zero size array
         // avoid deref of begin for zero size array
         if (!chunk.empty()) {
         if (!chunk.empty()) {
           *this->LogFile << "   Curl output was: "
           *this->LogFile << "   Curl output was: "
-                         << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                         << cmCTestLogWrite(chunk.data(), chunk.size())
                          << std::endl;
                          << std::endl;
           cmCTestLog(this->CTest, ERROR_MESSAGE,
           cmCTestLog(this->CTest, ERROR_MESSAGE,
                      "CURL output: ["
                      "CURL output: ["
-                       << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+                       << cmCTestLogWrite(chunk.data(), chunk.size()) << "]"
                        << std::endl);
                        << std::endl);
         }
         }
         ::curl_easy_cleanup(curl);
         ::curl_easy_cleanup(curl);
@@ -486,7 +485,7 @@ void cmCTestSubmitHandler::ParseResponse(
   if (this->HasWarnings || this->HasErrors) {
   if (this->HasWarnings || this->HasErrors) {
     cmCTestLog(this->CTest, HANDLER_OUTPUT,
     cmCTestLog(this->CTest, HANDLER_OUTPUT,
                "   Server Response:\n"
                "   Server Response:\n"
-                 << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
+                 << cmCTestLogWrite(chunk.data(), chunk.size()) << "\n");
   }
   }
 }
 }
 
 

+ 2 - 2
Source/CTest/cmProcess.cxx

@@ -199,7 +199,7 @@ bool cmProcess::Buffer::GetLine(std::string& line)
   for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
   for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
     if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
     if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
       // Extract the range first..last as a line.
       // Extract the range first..last as a line.
-      const char* text = &*this->begin() + this->First;
+      const char* text = this->data() + this->First;
       size_type length = this->Last - this->First;
       size_type length = this->Last - this->First;
       while (length && text[length - 1] == '\r') {
       while (length && text[length - 1] == '\r') {
         length--;
         length--;
@@ -229,7 +229,7 @@ bool cmProcess::Buffer::GetLast(std::string& line)
 {
 {
   // Return the partial last line, if any.
   // Return the partial last line, if any.
   if (!this->empty()) {
   if (!this->empty()) {
-    line.assign(&*this->begin(), this->size());
+    line.assign(this->data(), this->size());
     this->First = this->Last = 0;
     this->First = this->Last = 0;
     this->clear();
     this->clear();
     return true;
     return true;

+ 7 - 7
Source/cmCTest.cxx

@@ -1039,7 +1039,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
 
 
   // Now create process object
   // Now create process object
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
   cmsysProcess_SetTimeout(cp, timeout.count());
   cmsysProcess_SetTimeout(cp, timeout.count());
@@ -1222,7 +1222,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
   }
   }
 
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl);
   cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl);
   if (cmSystemTools::GetRunCommandHideConsole()) {
   if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
@@ -1258,7 +1258,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
   cmsysProcess_WaitForExit(cp, nullptr);
   cmsysProcess_WaitForExit(cp, nullptr);
   processOutput.DecodeText(tempOutput, tempOutput);
   processOutput.DecodeText(tempOutput, tempOutput);
   if (output && tempOutput.begin() != tempOutput.end()) {
   if (output && tempOutput.begin() != tempOutput.end()) {
-    output->append(&*tempOutput.begin(), tempOutput.size());
+    output->append(tempOutput.data(), tempOutput.size());
   }
   }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
              "-- Process completed" << std::endl);
              "-- Process completed" << std::endl);
@@ -2776,7 +2776,7 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
   stdErr->clear();
   stdErr->clear();
 
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetWorkingDirectory(cp, dir);
   if (cmSystemTools::GetRunCommandHideConsole()) {
   if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
@@ -2820,11 +2820,11 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
   cmsysProcess_WaitForExit(cp, nullptr);
   cmsysProcess_WaitForExit(cp, nullptr);
   if (!tempOutput.empty()) {
   if (!tempOutput.empty()) {
     processOutput.DecodeText(tempOutput, tempOutput);
     processOutput.DecodeText(tempOutput, tempOutput);
-    stdOut->append(&*tempOutput.begin(), tempOutput.size());
+    stdOut->append(tempOutput.data(), tempOutput.size());
   }
   }
   if (!tempError.empty()) {
   if (!tempError.empty()) {
     processOutput.DecodeText(tempError, tempError);
     processOutput.DecodeText(tempError, tempError);
-    stdErr->append(&*tempError.begin(), tempError.size());
+    stdErr->append(tempError.data(), tempError.size());
   }
   }
 
 
   bool result = true;
   bool result = true;
@@ -3048,7 +3048,7 @@ void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
 {
 {
   std::string test_outputs("\n*** Test Failed:\n");
   std::string test_outputs("\n*** Test Failed:\n");
   if (!process_output.empty()) {
   if (!process_output.empty()) {
-    test_outputs.append(&*process_output.begin(), process_output.size());
+    test_outputs.append(process_output.data(), process_output.size());
   }
   }
   cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
   cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
 }
 }

+ 2 - 2
Source/cmConditionEvaluator.cxx

@@ -130,8 +130,8 @@ bool cmConditionEvaluator::IsTrue(
     return false;
     return false;
   }
   }
 
 
-  return this->GetBooleanValueWithAutoDereference(*(newArgs.begin()),
-                                                  errorString, status, true);
+  return this->GetBooleanValueWithAutoDereference(newArgs.front(), errorString,
+                                                  status, true);
 }
 }
 
 
 //=========================================================================
 //=========================================================================

+ 3 - 3
Source/cmExecuteProcessCommand.cxx

@@ -193,7 +193,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
 
 
   // Set the command sequence.
   // Set the command sequence.
   for (auto const& cmd : cmds) {
   for (auto const& cmd : cmds) {
-    cmsysProcess_AddCommand(cp, &*cmd.begin());
+    cmsysProcess_AddCommand(cp, cmd.data());
   }
   }
 
 
   // Set the process working directory.
   // Set the process working directory.
@@ -286,10 +286,10 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
 
 
   // Store the output obtained.
   // Store the output obtained.
   if (!output_variable.empty() && !tempOutput.empty()) {
   if (!output_variable.empty() && !tempOutput.empty()) {
-    this->Makefile->AddDefinition(output_variable, &*tempOutput.begin());
+    this->Makefile->AddDefinition(output_variable, tempOutput.data());
   }
   }
   if (!merge_output && !error_variable.empty() && !tempError.empty()) {
   if (!merge_output && !error_variable.empty() && !tempError.empty()) {
-    this->Makefile->AddDefinition(error_variable, &*tempError.begin());
+    this->Makefile->AddDefinition(error_variable, tempError.data());
   }
   }
 
 
   // Store the result of running the process.
   // Store the result of running the process.

+ 3 - 3
Source/cmFileCommand.cxx

@@ -3067,7 +3067,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 
 
   if (!logVar.empty()) {
   if (!logVar.empty()) {
     chunkDebug.push_back(0);
     chunkDebug.push_back(0);
-    this->Makefile->AddDefinition(logVar, &*chunkDebug.begin());
+    this->Makefile->AddDefinition(logVar, chunkDebug.data());
   }
   }
 
 
   return true;
   return true;
@@ -3326,14 +3326,14 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
     if (!chunkResponse.empty()) {
     if (!chunkResponse.empty()) {
       chunkResponse.push_back(0);
       chunkResponse.push_back(0);
       log += "Response:\n";
       log += "Response:\n";
-      log += &*chunkResponse.begin();
+      log += chunkResponse.data();
       log += "\n";
       log += "\n";
     }
     }
 
 
     if (!chunkDebug.empty()) {
     if (!chunkDebug.empty()) {
       chunkDebug.push_back(0);
       chunkDebug.push_back(0);
       log += "Debug:\n";
       log += "Debug:\n";
-      log += &*chunkDebug.begin();
+      log += chunkDebug.data();
       log += "\n";
       log += "\n";
     }
     }
 
 

+ 1 - 1
Source/cmFilePathChecksum.cxx

@@ -74,7 +74,7 @@ std::string cmFilePathChecksum::get(std::string const& filePath) const
     cmCryptoHash(cmCryptoHash::AlgoSHA256).ByteHashString(relSeed + relPath);
     cmCryptoHash(cmCryptoHash::AlgoSHA256).ByteHashString(relSeed + relPath);
 
 
   // Convert binary checksum to string
   // Convert binary checksum to string
-  return cmBase32Encoder().encodeString(&hashBytes.front(), hashBytes.size(),
+  return cmBase32Encoder().encodeString(hashBytes.data(), hashBytes.size(),
                                         false);
                                         false);
 }
 }
 
 

+ 1 - 1
Source/cmFindCommon.cxx

@@ -310,7 +310,7 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
 
 
 void AddTrailingSlash(std::string& s)
 void AddTrailingSlash(std::string& s)
 {
 {
-  if (!s.empty() && *s.rbegin() != '/') {
+  if (!s.empty() && s.back() != '/') {
     s += '/';
     s += '/';
   }
   }
 }
 }

+ 1 - 1
Source/cmFindPackageCommand.cxx

@@ -466,7 +466,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
     // Allocate a PACKAGE_ROOT_PATH for the current find_package call.
     // Allocate a PACKAGE_ROOT_PATH for the current find_package call.
     this->Makefile->FindPackageRootPathStack.emplace_back();
     this->Makefile->FindPackageRootPathStack.emplace_back();
     std::vector<std::string>& rootPaths =
     std::vector<std::string>& rootPaths =
-      *this->Makefile->FindPackageRootPathStack.rbegin();
+      this->Makefile->FindPackageRootPathStack.back();
 
 
     // Add root paths from <PackageName>_ROOT CMake and environment variables,
     // Add root paths from <PackageName>_ROOT CMake and environment variables,
     // subject to CMP0074.
     // subject to CMP0074.

+ 16 - 16
Source/cmGeneratorExpressionNode.cxx

@@ -135,13 +135,13 @@ static const struct NotNode : public cmGeneratorExpressionNode
     const GeneratorExpressionContent* content,
     const GeneratorExpressionContent* content,
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
   {
   {
-    if (*parameters.begin() != "0" && *parameters.begin() != "1") {
+    if (parameters.front() != "0" && parameters.front() != "1") {
       reportError(
       reportError(
         context, content->GetOriginalExpression(),
         context, content->GetOriginalExpression(),
         "$<NOT> parameter must resolve to exactly one '0' or '1' value.");
         "$<NOT> parameter must resolve to exactly one '0' or '1' value.");
       return std::string();
       return std::string();
     }
     }
-    return *parameters.begin() == "0" ? "1" : "0";
+    return parameters.front() == "0" ? "1" : "0";
   }
   }
 } notNode;
 } notNode;
 
 
@@ -157,7 +157,7 @@ static const struct BoolNode : public cmGeneratorExpressionNode
     const GeneratorExpressionContent* /*content*/,
     const GeneratorExpressionContent* /*content*/,
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
   {
   {
-    return !cmSystemTools::IsOff(*parameters.begin()) ? "1" : "0";
+    return !cmSystemTools::IsOff(parameters.front()) ? "1" : "0";
   }
   }
 } boolNode;
 } boolNode;
 
 
@@ -194,7 +194,7 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode
     const GeneratorExpressionContent* /*content*/,
     const GeneratorExpressionContent* /*content*/,
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
     cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
   {
   {
-    return *parameters.begin() == parameters[1] ? "1" : "0";
+    return parameters.front() == parameters[1] ? "1" : "0";
   }
   }
 } strEqualNode;
 } strEqualNode;
 
 
@@ -613,7 +613,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
       return compilerId;
       return compilerId;
     }
     }
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
-    if (!compilerIdValidator.find(*parameters.begin())) {
+    if (!compilerIdValidator.find(parameters.front())) {
       reportError(context, content->GetOriginalExpression(),
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
                   "Expression syntax not recognized.");
       return std::string();
       return std::string();
@@ -622,11 +622,11 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
       return parameters.front().empty() ? "1" : "0";
       return parameters.front().empty() ? "1" : "0";
     }
     }
 
 
-    if (strcmp(parameters.begin()->c_str(), compilerId.c_str()) == 0) {
+    if (strcmp(parameters.front().c_str(), compilerId.c_str()) == 0) {
       return "1";
       return "1";
     }
     }
 
 
-    if (cmsysString_strcasecmp(parameters.begin()->c_str(),
+    if (cmsysString_strcasecmp(parameters.front().c_str(),
                                compilerId.c_str()) == 0) {
                                compilerId.c_str()) == 0) {
       switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
       switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
         case cmPolicies::WARN: {
         case cmPolicies::WARN: {
@@ -734,7 +734,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
     }
     }
 
 
     static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
     static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
-    if (!compilerIdValidator.find(*parameters.begin())) {
+    if (!compilerIdValidator.find(parameters.front())) {
       reportError(context, content->GetOriginalExpression(),
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
                   "Expression syntax not recognized.");
       return std::string();
       return std::string();
@@ -744,7 +744,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
     }
     }
 
 
     return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
     return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
-                                         parameters.begin()->c_str(),
+                                         parameters.front().c_str(),
                                          compilerVersion.c_str())
                                          compilerVersion.c_str())
       ? "1"
       ? "1"
       : "0";
       : "0";
@@ -839,7 +839,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
       return parameters.front().empty() ? "1" : "0";
       return parameters.front().empty() ? "1" : "0";
     }
     }
 
 
-    if (*parameters.begin() == platformId) {
+    if (parameters.front() == platformId) {
       return "1";
       return "1";
     }
     }
     return "0";
     return "0";
@@ -1001,7 +1001,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
       return configurationNode.Evaluate(parameters, context, content, nullptr);
       return configurationNode.Evaluate(parameters, context, content, nullptr);
     }
     }
     static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
     static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
-    if (!configValidator.find(*parameters.begin())) {
+    if (!configValidator.find(parameters.front())) {
       reportError(context, content->GetOriginalExpression(),
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
                   "Expression syntax not recognized.");
       return std::string();
       return std::string();
@@ -1011,7 +1011,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
       return parameters.front().empty() ? "1" : "0";
       return parameters.front().empty() ? "1" : "0";
     }
     }
 
 
-    if (cmsysString_strcasecmp(parameters.begin()->c_str(),
+    if (cmsysString_strcasecmp(parameters.front().c_str(),
                                context->Config.c_str()) == 0) {
                                context->Config.c_str()) == 0) {
       return "1";
       return "1";
     }
     }
@@ -1166,7 +1166,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
     static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
     static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
 
 
     cmGeneratorTarget const* target = context->HeadTarget;
     cmGeneratorTarget const* target = context->HeadTarget;
-    std::string propertyName = *parameters.begin();
+    std::string propertyName = parameters.front();
 
 
     if (parameters.size() == 1) {
     if (parameters.size() == 1) {
       context->HadHeadSensitiveCondition = true;
       context->HadHeadSensitiveCondition = true;
@@ -1182,14 +1182,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
     }
     }
 
 
     if (parameters.size() == 2) {
     if (parameters.size() == 2) {
-      if (parameters.begin()->empty() && parameters[1].empty()) {
+      if (parameters.front().empty() && parameters[1].empty()) {
         reportError(
         reportError(
           context, content->GetOriginalExpression(),
           context, content->GetOriginalExpression(),
           "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
           "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
           "target name and property name.");
           "target name and property name.");
         return std::string();
         return std::string();
       }
       }
-      if (parameters.begin()->empty()) {
+      if (parameters.front().empty()) {
         reportError(
         reportError(
           context, content->GetOriginalExpression(),
           context, content->GetOriginalExpression(),
           "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
           "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
@@ -1964,7 +1964,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
     cmGeneratorExpressionDAGChecker* dagChecker) const override
     cmGeneratorExpressionDAGChecker* dagChecker) const override
   {
   {
     // Lookup the referenced target.
     // Lookup the referenced target.
-    std::string name = *parameters.begin();
+    std::string name = parameters.front();
 
 
     if (!cmGeneratorExpression::IsValidTargetName(name)) {
     if (!cmGeneratorExpression::IsValidTargetName(name)) {
       ::reportError(context, content->GetOriginalExpression(),
       ::reportError(context, content->GetOriginalExpression(),

+ 3 - 3
Source/cmGeneratorExpressionParser.cxx

@@ -47,11 +47,11 @@ static void extendResult(
   if (!result.empty() &&
   if (!result.empty() &&
       (*(result.end() - 1))->GetType() ==
       (*(result.end() - 1))->GetType() ==
         cmGeneratorExpressionEvaluator::Text &&
         cmGeneratorExpressionEvaluator::Text &&
-      (*contents.begin())->GetType() == cmGeneratorExpressionEvaluator::Text) {
+      contents.front()->GetType() == cmGeneratorExpressionEvaluator::Text) {
     TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
     TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
     textContent->Extend(
     textContent->Extend(
-      static_cast<TextContent*>(*contents.begin())->GetLength());
-    delete *contents.begin();
+      static_cast<TextContent*>(contents.front())->GetLength());
+    delete contents.front();
     result.insert(result.end(), contents.begin() + 1, contents.end());
     result.insert(result.end(), contents.begin() + 1, contents.end());
   } else {
   } else {
     result.insert(result.end(), contents.begin(), contents.end());
     result.insert(result.end(), contents.begin(), contents.end());

+ 1 - 1
Source/cmGeneratorTarget.cxx

@@ -2389,7 +2389,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
   std::set<cmGeneratorTarget*> targets;
   std::set<cmGeneratorTarget*> targets;
 
 
   for (cmCustomCommandLine const& cCmdLine : cc.GetCommandLines()) {
   for (cmCustomCommandLine const& cCmdLine : cc.GetCommandLines()) {
-    std::string const& command = *cCmdLine.begin();
+    std::string const& command = cCmdLine.front();
     // Check for a target with this name.
     // Check for a target with this name.
     if (cmGeneratorTarget* t =
     if (cmGeneratorTarget* t =
           this->LocalGenerator->FindGeneratorTargetToUse(command)) {
           this->LocalGenerator->FindGeneratorTargetToUse(command)) {

+ 1 - 1
Source/cmMakefile.cxx

@@ -2193,7 +2193,7 @@ cmSourceGroup* cmMakefile::FindSourceGroup(
   }
   }
 
 
   // Shouldn't get here, but just in case, return the default group.
   // Shouldn't get here, but just in case, return the default group.
-  return &groups.front();
+  return groups.data();
 }
 }
 #endif
 #endif
 
 

+ 3 - 3
Source/cmQtAutoGenerator.cxx

@@ -447,7 +447,7 @@ void cmQtAutoGenerator::ReadOnlyProcessT::PipeT::UVAlloc(uv_handle_t* handle,
 {
 {
   auto& pipe = *reinterpret_cast<PipeT*>(handle->data);
   auto& pipe = *reinterpret_cast<PipeT*>(handle->data);
   pipe.Buffer_.resize(suggestedSize);
   pipe.Buffer_.resize(suggestedSize);
-  buf->base = &pipe.Buffer_.front();
+  buf->base = pipe.Buffer_.data();
   buf->len = pipe.Buffer_.size();
   buf->len = pipe.Buffer_.size();
 }
 }
 
 
@@ -555,11 +555,11 @@ bool cmQtAutoGenerator::ReadOnlyProcessT::start(
     std::fill_n(reinterpret_cast<char*>(&UVOptions_), sizeof(UVOptions_), 0);
     std::fill_n(reinterpret_cast<char*>(&UVOptions_), sizeof(UVOptions_), 0);
     UVOptions_.exit_cb = &ReadOnlyProcessT::UVExit;
     UVOptions_.exit_cb = &ReadOnlyProcessT::UVExit;
     UVOptions_.file = CommandPtr_[0];
     UVOptions_.file = CommandPtr_[0];
-    UVOptions_.args = const_cast<char**>(&CommandPtr_.front());
+    UVOptions_.args = const_cast<char**>(CommandPtr_.data());
     UVOptions_.cwd = Setup_.WorkingDirectory.c_str();
     UVOptions_.cwd = Setup_.WorkingDirectory.c_str();
     UVOptions_.flags = UV_PROCESS_WINDOWS_HIDE;
     UVOptions_.flags = UV_PROCESS_WINDOWS_HIDE;
     UVOptions_.stdio_count = static_cast<int>(UVOptionsStdIO_.size());
     UVOptions_.stdio_count = static_cast<int>(UVOptionsStdIO_.size());
-    UVOptions_.stdio = &UVOptionsStdIO_.front();
+    UVOptions_.stdio = UVOptionsStdIO_.data();
 
 
     // -- Spawn process
     // -- Spawn process
     if (UVProcess_.spawn(*uv_loop, UVOptions_, this) != 0) {
     if (UVProcess_.spawn(*uv_loop, UVOptions_, this) != 0) {

+ 2 - 2
Source/cmSearchPath.cxx

@@ -144,7 +144,7 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
     // this will get incorrectly considered a network
     // this will get incorrectly considered a network
     // path on windows and cause huge delays.
     // path on windows and cause huge delays.
     std::string p = inPath;
     std::string p = inPath;
-    if (!p.empty() && *p.rbegin() != '/') {
+    if (!p.empty() && p.back() != '/') {
       p += "/";
       p += "/";
     }
     }
 
 
@@ -176,7 +176,7 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
 
 
   for (std::string const& path : paths) {
   for (std::string const& path : paths) {
     std::string dir = path;
     std::string dir = path;
-    if (!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') {
+    if (!subdir.empty() && !dir.empty() && dir.back() != '/') {
       dir += "/";
       dir += "/";
     }
     }
     if (subdir == "include" || subdir == "lib") {
     if (subdir == "include" || subdir == "lib") {

+ 1 - 1
Source/cmStringCommand.cxx

@@ -771,7 +771,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
   }
   }
   result.push_back(0);
   result.push_back(0);
 
 
-  this->Makefile->AddDefinition(variableName, &*result.begin());
+  this->Makefile->AddDefinition(variableName, result.data());
   return true;
   return true;
 }
 }
 
 

+ 1 - 1
Source/cmSystemTools.cxx

@@ -740,7 +740,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
   argv.push_back(nullptr);
   argv.push_back(nullptr);
 
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetWorkingDirectory(cp, dir);
   if (cmSystemTools::GetRunCommandHideConsole()) {
   if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);

+ 1 - 1
Source/cmakexbuild.cxx

@@ -22,7 +22,7 @@ int RunXCode(std::vector<const char*>& argv, bool& hitbug)
 {
 {
   hitbug = false;
   hitbug = false;
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess* cp = cmsysProcess_New();
-  cmsysProcess_SetCommand(cp, &*argv.begin());
+  cmsysProcess_SetCommand(cp, argv.data());
   cmsysProcess_SetTimeout(cp, 0);
   cmsysProcess_SetTimeout(cp, 0);
   cmsysProcess_Execute(cp);
   cmsysProcess_Execute(cp);
   std::vector<char> out;
   std::vector<char> out;