diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-12-13 07:31:16 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-13 07:12:12 -0500 |
commit | 474fc72e32f78d55ca8bc795e0d257813c7c4b8a (patch) | |
tree | 6872a1c1f71d9f2e5bd1cd41f0613cf83b8d615b /qt-models | |
parent | bf7954ebe7fa7c1f9c7ca77655f35500ffb057fb (diff) | |
download | subsurface-474fc72e32f78d55ca8bc795e0d257813c7c4b8a.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divetripmodel.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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<dive *> // 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<const dive *>(), // Condition: dive-pointers are equal [&](const std::vector<dive *> &, const QVector<dive *> &, 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<dive *> &d QVector<dive *> 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<const dive *>(), // Condition: dive-pointers are equal [&](std::vector<dive *> &items, const QVector<dive *> &, 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<dive *> &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<const dive *>(), // Condition: dive-pointers are equal [&](const std::vector<dive *> &, const QVector<dive *> &, 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)); |