Merge pull request #20142 from bofdahof/ranges

Apply C++20 std::ranges (mainly to std::find)
This commit is contained in:
Chris Hennes
2025-03-17 03:08:27 -05:00
committed by GitHub
93 changed files with 485 additions and 662 deletions

View File

@@ -295,13 +295,12 @@ void TaskPipeParameters::onDeleteEdge()
delete item;
// search inside the list of spines
auto pipe = getObject<PartDesign::Pipe>();
const auto pipe = getObject<PartDesign::Pipe>();
std::vector<std::string> refs = pipe->Spine.getSubValues();
std::string obj = data.constData();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), obj);
const std::string obj = data.constData();
// if something was found, delete it and update the spine list
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs, obj); f != refs.end()) {
refs.erase(f);
pipe->Spine.setValue(pipe->Spine.getValue(), refs);
clearButtons();
@@ -340,7 +339,7 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const
std::vector<App::DocumentObject*> sections = pipe->Sections.getValues();
// cannot use the same object for profile and section
if (std::find(sections.begin(), sections.end(), profile) != sections.end()) {
if (std::ranges::find(sections, profile) != sections.end()) {
success = false;
}
else {
@@ -359,10 +358,10 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const
case StateHandlerTaskPipe::SelectionModes::refSpineEdgeAdd:
case StateHandlerTaskPipe::SelectionModes::refSpineEdgeRemove: {
// change the references
std::string subName(msg.pSubName);
auto pipe = getObject<PartDesign::Pipe>();
const std::string subName(msg.pSubName);
const auto pipe = getObject<PartDesign::Pipe>();
std::vector<std::string> refs = pipe->Spine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
const auto f = std::ranges::find(refs, subName);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refSpine) {
getViewObject<ViewProviderPipe>()->highlightReferences(ViewProviderPipe::Spine,
@@ -793,11 +792,11 @@ bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const
return false;
}
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
// change the references
std::string subName(msg.pSubName);
const std::string subName(msg.pSubName);
std::vector<std::string> refs = pipe->AuxillerySpine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
const auto f = std::ranges::find(refs, subName);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refAuxSpine) {
refs.clear();
@@ -847,13 +846,12 @@ void TaskPipeOrientation::onDeleteItem()
delete item;
// search inside the list of spines
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<std::string> refs = pipe->AuxillerySpine.getSubValues();
std::string obj = data.constData();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), obj);
const std::string obj = data.constData();
// if something was found, delete it and update the spine list
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs, obj); f != refs.end()) {
refs.erase(f);
pipe->AuxillerySpine.setValue(pipe->AuxillerySpine.getValue(), refs);
clearButtons();
@@ -1049,11 +1047,10 @@ bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const
}
// change the references
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<App::DocumentObject*> refs = pipe->Sections.getValues();
App::DocumentObject* obj = pipe->getDocument()->getObject(msg.pObjectName);
std::vector<App::DocumentObject*>::iterator f =
std::find(refs.begin(), refs.end(), obj);
const auto f = std::ranges::find(refs, obj);
if (selectionMode == StateHandlerTaskPipe::SelectionModes::refSectionAdd) {
if (f != refs.end()) {
@@ -1101,13 +1098,11 @@ void TaskPipeScaling::onDeleteSection()
.first->getNameInDocument());
delete item;
if (auto pipe = getObject<PartDesign::Pipe>()) {
if (const auto pipe = getObject<PartDesign::Pipe>()) {
std::vector<App::DocumentObject*> refs = pipe->Sections.getValues();
App::DocumentObject* obj = pipe->getDocument()->getObject(data.constData());
std::vector<App::DocumentObject*>::iterator f =
std::find(refs.begin(), refs.end(), obj);
if (f != refs.end()) {
if (const auto f = std::ranges::find(refs.begin(), refs.end(), obj); f != refs.end()) {
pipe->Sections.removeValue(obj);
clearButtons();
recomputeFeature();