From ffc91b4f26647b1066ab5694b356db7088fa48a3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 30 Dec 2020 16:45:20 +0000 Subject: Fix client compile with clang --- gentoobrowse-api/client/helpers.h | 15 +++++++-------- gentoobrowse-api/client/search.cpp | 5 ++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gentoobrowse-api/client/helpers.h b/gentoobrowse-api/client/helpers.h index 96399d2..4caf7f9 100644 --- a/gentoobrowse-api/client/helpers.h +++ b/gentoobrowse-api/client/helpers.h @@ -7,21 +7,20 @@ #include #include -template +template std::map -asyncMapRelated(const Collection & collection, const Proxy & p, Key Collection::value_type::element_type::*member, +asyncMapRelated(const Collection & collection, const Proxy & p, Key CollectionMember::*member, std::future (Proxy::element_type::*b)(Key, const ::Ice::Context &)) { - std::map rtn; std::map> jobs; for (const auto & item : collection) { - Key v = item.get()->*member; - if (jobs.find(v) == jobs.end()) { - jobs.insert({v, (p.get()->*b)(v, Ice::noExplicitContext)}); + if (Key v = item.get()->*member; jobs.find(v) == jobs.end()) { + jobs.emplace(v, (p.get()->*b)(v, Ice::noExplicitContext)); } } - for (auto & j : jobs) { - rtn.insert({j.first, j.second.get()}); + std::map rtn; + for (auto & [cat, future] : jobs) { + rtn.emplace(cat, future.get()); } return rtn; } diff --git a/gentoobrowse-api/client/search.cpp b/gentoobrowse-api/client/search.cpp index 9d1c7b4..5de8d3b 100644 --- a/gentoobrowse-api/client/search.cpp +++ b/gentoobrowse-api/client/search.cpp @@ -10,9 +10,8 @@ public: run(const Gentoo::PortagePrxPtr & p, const std::vector & a) const override { auto pkgs = p->getPackagesSearch(boost::algorithm::join(a, " ")); - auto cats = asyncMapRelated(pkgs, p, &Gentoo::Package::categoryid, - (std::future(Gentoo::PortagePrx::*)(Ice::Int, const ::Ice::Context &)) - & Gentoo::PortagePrx::getCategoryAsync); + auto cats = asyncMapRelated( + pkgs, p, &Gentoo::Package::categoryid, &Gentoo::PortagePrx::getCategoryAsync); fprintbf(stdout, "Found %d packages:\n", pkgs.size()); for (const auto & pkg : pkgs) { fprintbf(stdout, "%s / %s\n\t%s\n", cats[pkg->categoryid]->name, pkg->name, pkg->description); -- cgit v1.2.3