From 2b734a7ec429825c7007c1093883229e069d36c7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 8 Jul 2019 15:48:59 +0200 Subject: Apply various suggestions by cppcheck Reported-By: cppcheck --- apt-private/private-cmndline.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apt-private/private-cmndline.cc') diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 3f43d6eb1..5944e530d 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -508,15 +509,15 @@ std::vector ParseCommandLine(CommandLine &CmdL, APT_CMD c if (likely(argc != 0 && argv[0] != NULL)) BinarySpecificConfiguration(argv[0]); - std::vector const CmdsWithHelp = GetCommands(); std::vector Cmds; + std::vector const CmdsWithHelp = GetCommands(); if (CmdsWithHelp.empty() == false) { CommandLine::Dispatch const help = { "help", [](CommandLine &){return false;} }; Cmds.push_back(std::move(help)); } - for (auto const& cmd : CmdsWithHelp) - Cmds.push_back({cmd.Match, cmd.Handler}); + std::transform(CmdsWithHelp.begin(), CmdsWithHelp.end(), std::back_inserter(Cmds), + [](auto &&cmd) { return CommandLine::Dispatch{cmd.Match, cmd.Handler}; }); char const * CmdCalled = nullptr; if (Cmds.empty() == false && Cmds[0].Handler != nullptr) -- cgit v1.2.3