summaryrefslogtreecommitdiff
path: root/cmdline/apt-mark.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-09-17 13:13:41 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-04 18:04:00 +0100
commit2fc9d1ebca203b4a159dba5e817081155099f6ab (patch)
tree3847340b1e577da59703dcdd3bf3960a2a4d587a /cmdline/apt-mark.cc
parentb2a893dda28aea05128394cd61c7ce38cfa0624b (diff)
add cacheset push_back wrapping for std::back_inserter
As usual by now, not all containers wrapped by the cacheset containers support all methods, like push_back now, but they fail on use of these unusable methods only. Would be nice to not expose these methods for unsupporting containers at all, but that means either a lot of classes or a lot of std::enable_if magic, which seems like too big work for this small wrapper for now. Git-Dch: Ignore
Diffstat (limited to 'cmdline/apt-mark.cc')
-rw-r--r--cmdline/apt-mark.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index 9b51345a3..d9a93fa05 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -180,13 +180,13 @@ static bool DoHold(CommandLine &CmdL)
bool const MarkHold = strcasecmp(CmdL.FileList[0],"hold") == 0;
- auto part = std::stable_partition(pkgset.begin(), pkgset.end(),
+ auto const part = std::stable_partition(pkgset.begin(), pkgset.end(),
[](pkgCache::PkgIterator const &P) { return P->SelectedState == pkgCache::State::Hold; });
- auto doneBegin = MarkHold ? pkgset.begin() : part;
- auto doneEnd = MarkHold ? part : pkgset.end();
- auto changeBegin = MarkHold ? part : pkgset.begin();
- auto changeEnd = MarkHold ? pkgset.end() : part;
+ auto const doneBegin = MarkHold ? pkgset.begin() : part;
+ auto const doneEnd = MarkHold ? part : pkgset.end();
+ auto const changeBegin = MarkHold ? part : pkgset.begin();
+ auto const changeEnd = MarkHold ? pkgset.end() : part;
std::for_each(doneBegin, doneEnd, [&MarkHold](pkgCache::PkgIterator const &P) {
if (MarkHold == true)
@@ -238,12 +238,8 @@ static bool DoHold(CommandLine &CmdL)
}
APT::PackageList keepoffset;
- for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
- {
- if (Pkg->CurrentVer != 0)
- continue;
- keepoffset.insert(*Pkg);
- }
+ std::copy_if(changeBegin, changeEnd, std::back_inserter(keepoffset),
+ [](pkgCache::PkgIterator const &P) { return P->CurrentVer == 0; });
if (keepoffset.empty() == false)
{