From b6f331f4fa9f36936128c956458d06bc67fd6cb0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 7 Aug 2023 13:31:19 +0200 Subject: [PATCH] modernize C++: use transparent functors --- src/App/ElementMap.h | 2 +- src/Gui/ShortcutManager.cpp | 2 +- src/Mod/Mesh/App/Core/Builder.cpp | 2 +- src/Mod/Mesh/App/Core/Degeneration.cpp | 4 ++-- src/Mod/Sketcher/Gui/CommandSketcherTools.cpp | 6 ++++-- src/Mod/Spreadsheet/Gui/SheetTableView.cpp | 4 ++-- src/Mod/TechDraw/App/DrawViewPart.cpp | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/App/ElementMap.h b/src/App/ElementMap.h index a617e0c59c..195b6020dd 100644 --- a/src/App/ElementMap.h +++ b/src/App/ElementMap.h @@ -267,7 +267,7 @@ private: std::map indexedNames; - std::map> mappedNames; + std::map> mappedNames; struct ChildMapInfo { diff --git a/src/Gui/ShortcutManager.cpp b/src/Gui/ShortcutManager.cpp index b35053f887..16830c514e 100644 --- a/src/Gui/ShortcutManager.cpp +++ b/src/Gui/ShortcutManager.cpp @@ -344,7 +344,7 @@ std::vector> ShortcutManager::getActionsByShortc { const auto &index = actionMap.get<1>(); std::vector> res; - std::multimap> map; + std::multimap> map; for (auto it = index.lower_bound(ActionKey(shortcut)); it != index.end(); ++it) { if (it->key.shortcut != shortcut) break; diff --git a/src/Mod/Mesh/App/Core/Builder.cpp b/src/Mod/Mesh/App/Core/Builder.cpp index 898cd4d95b..b61111f6af 100644 --- a/src/Mod/Mesh/App/Core/Builder.cpp +++ b/src/Mod/Mesh/App/Core/Builder.cpp @@ -337,7 +337,7 @@ void MeshFastBuilder::Finish () //std::sort(verts.begin(), verts.end()); int threads = QThread::idealThreadCount(); - MeshCore::parallel_sort(verts.begin(), verts.end(), std::less(), threads); + MeshCore::parallel_sort(verts.begin(), verts.end(), std::less<>(), threads); QVector indices(ulCtPts); diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index 54e5a4b107..d2d960c6ee 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -517,7 +517,7 @@ bool MeshRemoveNeedles::Fixup() std::priority_queue, - std::greater > todo; + std::greater<> > todo; for (std::size_t index = 0; index < facetCount; index++) { const MeshFacet& facet = rclFAry[index]; MeshGeomFacet tria(_rclMesh.GetFacet(facet)); @@ -615,7 +615,7 @@ bool MeshFixCaps::Fixup() std::priority_queue, - std::greater > todo; + std::greater<> > todo; for (std::size_t index = 0; index < facetCount; index++) { for (int i=0; i<3; i++) { const MeshFacet& facet = rclFAry[index]; diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 92e293ce4f..0692c65983 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -50,7 +50,8 @@ #include "Utils.h" #include "ViewProviderSketch.h" - +// Hint: this is to prevent to re-format big parts of the file. Remove it later again. +// clang-format off using namespace std; using namespace SketcherGui; using namespace Sketcher; @@ -806,7 +807,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) // Handle highest GeoIds first to minimize GeoIds changing // TODO: this might not completely resolve GeoIds changing - std::sort(SubGeoIds.begin(), SubGeoIds.end(), std::greater()); + std::sort(SubGeoIds.begin(), SubGeoIds.end(), std::greater<>()); // Keep unique SubGeoIds.erase(std::unique(SubGeoIds.begin(), SubGeoIds.end()), SubGeoIds.end()); @@ -2277,3 +2278,4 @@ void CreateSketcherCommandsConstraintAccel() rcCmdMgr.addCommand(new CmdSketcherDeleteAllConstraints()); rcCmdMgr.addCommand(new CmdSketcherRemoveAxesAlignment()); } +// clang-format on diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp index bce7a09483..e7f588c898 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp @@ -370,7 +370,7 @@ void SheetTableView::removeRows() /* Make sure rows are sorted in descending order */ for (QModelIndexList::const_iterator it = rows.cbegin(); it != rows.cend(); ++it) sortedRows.push_back(it->row()); - std::sort(sortedRows.begin(), sortedRows.end(), std::greater()); + std::sort(sortedRows.begin(), sortedRows.end(), std::greater<>()); /* Remove rows */ Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Remove rows")); @@ -443,7 +443,7 @@ void SheetTableView::removeColumns() /* Make sure rows are sorted in descending order */ for (QModelIndexList::const_iterator it = cols.cbegin(); it != cols.cend(); ++it) sortedColumns.push_back(it->column()); - std::sort(sortedColumns.begin(), sortedColumns.end(), std::greater()); + std::sort(sortedColumns.begin(), sortedColumns.end(), std::greater<>()); /* Remove columns */ Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Remove rows")); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index a8d5a81b1c..45187a316a 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -748,7 +748,7 @@ std::vector DrawViewPart::getDimensions() const { std::vector result; std::vector children = getInList(); - std::sort(children.begin(), children.end(), std::less()); + std::sort(children.begin(), children.end(), std::less<>()); std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) { @@ -764,7 +764,7 @@ std::vector DrawViewPart::getBalloons() const { std::vector result; std::vector children = getInList(); - std::sort(children.begin(), children.end(), std::less()); + std::sort(children.begin(), children.end(), std::less<>()); std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) {