From: Wolfgang Bangerth Date: Wed, 21 Jun 2023 15:38:25 +0000 (-0600) Subject: Standardize on the idiom of calling std::erase after std::unique. X-Git-Tag: relicensing~855^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce4c56920043cea0ad1b8f27f0e3ef365ca3ca47;p=dealii.git 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(). --- 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)