diff options
author | David Kalnischkies <david@kalnischkies.de> | 2019-07-08 15:48:59 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2019-07-08 15:51:17 +0200 |
commit | 2b734a7ec429825c7007c1093883229e069d36c7 (patch) | |
tree | b67360f3201634c82f5a9e7dd84f47b28fa63acb /apt-private/private-cmndline.cc | |
parent | cbe90ee516d7f747f981e423f164f99eb767240b (diff) |
Apply various suggestions by cppcheck
Reported-By: cppcheck
Diffstat (limited to 'apt-private/private-cmndline.cc')
-rw-r--r-- | apt-private/private-cmndline.cc | 7 |
1 files changed, 4 insertions, 3 deletions
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 <stdlib.h> #include <string.h> +#include <algorithm> #include <iomanip> #include <vector> @@ -508,15 +509,15 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c if (likely(argc != 0 && argv[0] != NULL)) BinarySpecificConfiguration(argv[0]); - std::vector<aptDispatchWithHelp> const CmdsWithHelp = GetCommands(); std::vector<CommandLine::Dispatch> Cmds; + std::vector<aptDispatchWithHelp> 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) |