From ce4c56920043cea0ad1b8f27f0e3ef365ca3ca47 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 21 Jun 2023 09:38:25 -0600 Subject: [PATCH] Standardize on the idiom of calling std::erase after std::unique. This idiom is used in many other places. This patch changes a number of locations where we do the same thing but instead use a different idiom, using a temporary iterator and/or using resize() instead of erase(). --- include/deal.II/lac/affine_constraints.templates.h | 4 +--- source/base/parsed_convergence_table.cc | 4 ++-- source/lac/sparsity_tools.cc | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index f385c04284..1ad3527835 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -1326,9 +1326,7 @@ AffineConstraints::resolve_indices( // keep only the unique elements std::sort(indices.begin(), indices.end()); - std::vector::iterator it; - it = std::unique(indices.begin(), indices.end()); - indices.resize(it - indices.begin()); + indices.erase(std::unique(indices.begin(), indices.end()), indices.end()); } diff --git a/source/base/parsed_convergence_table.cc b/source/base/parsed_convergence_table.cc index 5c4f15b802..c27523bbd7 100644 --- a/source/base/parsed_convergence_table.cc +++ b/source/base/parsed_convergence_table.cc @@ -26,8 +26,8 @@ namespace get_unique_component_names(const std::vector &component_names) { auto elements = component_names; - auto last = std::unique(elements.begin(), elements.end()); - elements.resize(last - elements.begin()); + elements.erase(std::unique(elements.begin(), elements.end()), + elements.end()); return elements; } diff --git a/source/lac/sparsity_tools.cc b/source/lac/sparsity_tools.cc index 0d0087cb73..013bbfe5af 100644 --- a/source/lac/sparsity_tools.cc +++ b/source/lac/sparsity_tools.cc @@ -641,10 +641,9 @@ namespace SparsityTools std::sort(next_round_dofs.begin(), next_round_dofs.end()); // delete multiple entries - std::vector::iterator end_sorted; - end_sorted = - std::unique(next_round_dofs.begin(), next_round_dofs.end()); - next_round_dofs.erase(end_sorted, next_round_dofs.end()); + next_round_dofs.erase(std::unique(next_round_dofs.begin(), + next_round_dofs.end()), + next_round_dofs.end()); // eliminate dofs which are already numbered for (int s = next_round_dofs.size() - 1; s >= 0; --s) -- 2.39.5