From 474fc72e32f78d55ca8bc795e0d257813c7c4b8a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 13 Dec 2019 07:31:16 +0100 Subject: Coding style: use std::equal_to instead of lambda Use std::equal_to instead of lambdas that compare two dive pointers. One could argue over which version is more readable. For whatever it's worth, std::equal_to is more compact and expressive. This removes an old erroneous comment that stated that std::equal_to is only available since C++14. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index eea4fcdba..1d424b9f3 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -1108,7 +1108,7 @@ void DiveTripModelTree::divesChangedTrip(dive_trip *trip, const QVector // Change the dives in the trip. We do this range-wise. processRangesZip(items[idx].dives, dives, - [](const dive *d1, const dive *d2) { return d1 == d2; }, // Condition (std::equal_to only in C++14) + std::equal_to(), // Condition: dive-pointers are equal [&](const std::vector &, const QVector &, int from, int to, int) -> int { // Action // TODO: We might be smarter about which columns changed! dataChanged(createIndex(from, 0, idx), createIndex(to - 1, COLUMNS - 1, idx)); @@ -1410,7 +1410,7 @@ void DiveTripModelList::divesDeleted(dive_trip *, bool, const QVector &d QVector dives = divesIn; std::sort(dives.begin(), dives.end(), dive_less_than); processRangesZip(items, dives, - [](const dive *d1, const dive *d2) { return d1 == d2; }, // Condition (std::equal_to only in C++14) + std::equal_to(), // Condition: dive-pointers are equal [&](std::vector &items, const QVector &, int from, int to, int) -> int { // Action beginRemoveRows(QModelIndex(), from, to - 1); items.erase(items.begin() + from, items.begin() + to); @@ -1437,7 +1437,7 @@ void DiveTripModelList::divesChanged(const QVector &divesIn) // in dives as this must be the first that we encounter. Once we find a range, increase the // index accordingly. processRangesZip(items, dives, - [](const dive *d1, const dive *d2) { return d1 == d2; }, // Condition (std::equal_to only in C++14) + std::equal_to(), // Condition: dive-pointers are equal [&](const std::vector &, const QVector &, int from, int to, int) -> int { // Action // TODO: We might be smarter about which columns changed! dataChanged(createIndex(from, 0, noParent), createIndex(to - 1, COLUMNS - 1, noParent)); -- cgit v1.2.3-70-g09d2