From f504289a021b0296701428467c469cbdaa351923 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 16 Aug 2025 08:43:41 +0300 Subject: [PATCH] labels: ensure c++17 compatibility This broke the build earlier. --- lib/message/mu-labels.cc | 12 ++++++++---- mu/mu-cmd-label.cc | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/message/mu-labels.cc b/lib/message/mu-labels.cc index 13a789bc..39f7c623 100644 --- a/lib/message/mu-labels.cc +++ b/lib/message/mu-labels.cc @@ -99,6 +99,12 @@ Mu::Labels::parse_delta_label(const std::string &expr) return Ok(DeltaLabel{std::move(delta), std::move(label)}); } + +struct cmp_delta_label { // can not yet be a λ in C++17 + bool operator()(const DeltaLabel& dl1, const DeltaLabel& dl2) const { + return dl1.second < dl2.second; + } +}; std::pair Mu::Labels::updated_labels(const LabelVec& labels, const DeltaLabelVec& deltas) { @@ -108,11 +114,9 @@ Mu::Labels::updated_labels(const LabelVec& labels, const DeltaLabelVec& deltas) // comparison operator so "add" and "remove" deltas are considered "the same" // for the set; then fill the set from the end of the deltas vec to the begining, // so "the last one wins", as we want. - const auto cmp_delta_label=[](const DeltaLabel& dl1, const DeltaLabel& dl2) { - return dl1.second < dl2.second; - }; + // only one change per label, last one wins - std::set working_deltas{ + std::set working_deltas{ deltas.rbegin(), deltas.rend() }; diff --git a/mu/mu-cmd-label.cc b/mu/mu-cmd-label.cc index cb0131ff..30396fe5 100644 --- a/mu/mu-cmd-label.cc +++ b/mu/mu-cmd-label.cc @@ -216,7 +216,8 @@ import_labels_for_message(Mu::Store& store, const Options& opts, [](const auto& label) { return DeltaLabel{Delta::Add, label}; }); - const auto qres = [&]->Result{ + const auto qres = [&]() + ->Result{ // plan A: match by path if (auto qres_a{log_import_get_matching(store, "path:" + path)}; !qres_a) { log_import_err(opts, mu_format("failed to find by path: {}; try with message-id",