blob: 3065210a04b15c168ae2cbb742523e4194aa0f74 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From e91fb0618ce0a5d42f239d0fca602544858f0819 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 16 Aug 2022 08:44:18 -0700
4Subject: [PATCH] Remove using std::binary_function
5
6std::binary_function and std::unary_function are deprecated since c++11
7and removed in c++17, therefore remove it and use lambda functions to get same
8functionality implemented.
9
10Upstream-Status: Submitted [https://salsa.debian.org/apt-team/apt/-/merge_requests/253]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 ftparchive/apt-ftparchive.cc | 33 ++++++++++-----------------------
14 1 file changed, 10 insertions(+), 23 deletions(-)
15
16diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
17index 87ce9153c..56fdc2246 100644
18--- a/ftparchive/apt-ftparchive.cc
19+++ b/ftparchive/apt-ftparchive.cc
20@@ -48,6 +48,11 @@
21 using namespace std;
22 unsigned Quiet = 0;
23
24+auto ContentsCompare = [](const auto &a, const auto &b) { return a.ContentsMTime < b.ContentsMTime; };
25+auto DBCompare = [](const auto &a, const auto &b) { return a.BinCacheDB < b.BinCacheDB; };
26+auto SrcDBCompare = [](const auto &a, const auto &b) { return a.SrcCacheDB < b.SrcCacheDB; };
27+
28+
29 static struct timeval GetTimevalFromSteadyClock() /*{{{*/
30 {
31 auto const Time = std::chrono::steady_clock::now().time_since_epoch();
32@@ -116,24 +121,6 @@ struct PackageMap
33 bool SrcDone;
34 time_t ContentsMTime;
35
36- struct ContentsCompare : public binary_function<PackageMap,PackageMap,bool>
37- {
38- inline bool operator() (const PackageMap &x,const PackageMap &y)
39- {return x.ContentsMTime < y.ContentsMTime;};
40- };
41-
42- struct DBCompare : public binary_function<PackageMap,PackageMap,bool>
43- {
44- inline bool operator() (const PackageMap &x,const PackageMap &y)
45- {return x.BinCacheDB < y.BinCacheDB;};
46- };
47-
48- struct SrcDBCompare : public binary_function<PackageMap,PackageMap,bool>
49- {
50- inline bool operator() (const PackageMap &x,const PackageMap &y)
51- {return x.SrcCacheDB < y.SrcCacheDB;};
52- };
53-
54 void GetGeneral(Configuration &Setup,Configuration &Block);
55 bool GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats);
56 bool GenSources(Configuration &Setup,struct CacheDB::Stats &Stats);
57@@ -869,7 +856,7 @@ static bool DoGenerateContents(Configuration &Setup,
58 else
59 I->ContentsMTime = A.st_mtime;
60 }
61- stable_sort(PkgList.begin(),PkgList.end(),PackageMap::ContentsCompare());
62+ stable_sort(PkgList.begin(),PkgList.end(),ContentsCompare);
63
64 /* Now for Contents.. The process here is to do a make-like dependency
65 check. Each contents file is verified to be newer than the package files
66@@ -941,8 +928,8 @@ static bool Generate(CommandLine &CmdL)
67 LoadBinDir(PkgList,Setup);
68
69 // Sort by cache DB to improve IO locality.
70- stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
71- stable_sort(PkgList.begin(),PkgList.end(),PackageMap::SrcDBCompare());
72+ stable_sort(PkgList.begin(),PkgList.end(),DBCompare);
73+ stable_sort(PkgList.begin(),PkgList.end(),SrcDBCompare);
74
75 // Generate packages
76 if (_config->FindB("APT::FTPArchive::ContentsOnly", false) == false)
77@@ -993,8 +980,8 @@ static bool Clean(CommandLine &CmdL)
78 LoadBinDir(PkgList,Setup);
79
80 // Sort by cache DB to improve IO locality.
81- stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
82- stable_sort(PkgList.begin(),PkgList.end(),PackageMap::SrcDBCompare());
83+ stable_sort(PkgList.begin(),PkgList.end(),DBCompare);
84+ stable_sort(PkgList.begin(),PkgList.end(),SrcDBCompare);
85
86 string CacheDir = Setup.FindDir("Dir::CacheDir");
87