From: Wolfgang Bangerth Date: Fri, 30 Jun 2023 20:12:35 +0000 (-0600) Subject: Remove ill-defined (and poorly documented) comparison operators for AffineConstraints... X-Git-Tag: relicensing~834^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d1211d59fee241d0cd2dbff2d495e416ce4570c;p=dealii.git Remove ill-defined (and poorly documented) comparison operators for AffineConstraints::ConstraintLine. --- diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index dc01b2cc46..973324b63e 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -1668,24 +1668,6 @@ public: ConstraintLine & operator=(const ConstraintLineType &other); - /** - * This operator is a bit weird and unintuitive: it compares the line - * numbers of two lines. We need this to sort the lines; in fact we could - * do this using a comparison predicate. However, this way, it is easier, - * albeit unintuitive since two lines really have no god-given order - * relation. - */ - bool - operator<(const ConstraintLine &) const; - - /** - * This operator is likewise weird: it checks whether the line indices of - * the two operands are equal, irrespective of the fact that the contents - * of the line may be different. - */ - bool - operator==(const ConstraintLine &) const; - /** * Determine an estimate for the memory consumption (in bytes) of this * object. diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index b36d462e41..da30239ef1 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -62,26 +62,6 @@ DEAL_II_NAMESPACE_OPEN -template -bool -AffineConstraints::ConstraintLine::operator<( - const ConstraintLine &a) const -{ - return index < a.index; -} - - - -template -bool -AffineConstraints::ConstraintLine::operator==( - const ConstraintLine &a) const -{ - return index == a.index; -} - - - template std::size_t AffineConstraints::ConstraintLine::memory_consumption() const @@ -218,13 +198,25 @@ namespace internal Utilities::MPI::this_mpi_process(mpi_communicator); // helper function - const auto sort_and_make_unique = - [](std::vector &constraints) { - std::sort(constraints.begin(), constraints.end()); - - constraints.erase(std::unique(constraints.begin(), constraints.end()), - constraints.end()); - }; + const auto sort_and_make_unique = [](std::vector + &constraints) { + std::sort( + constraints.begin(), + constraints.end(), + [](const typename dealii::AffineConstraints::ConstraintLine &l1, + const typename dealii::AffineConstraints::ConstraintLine + &l2) { return l1.index < l2.index; }); + + constraints.erase( + std::unique( + constraints.begin(), + constraints.end(), + [](const typename dealii::AffineConstraints::ConstraintLine + &l1, + const typename dealii::AffineConstraints::ConstraintLine + &l2) { return l1.index == l2.index; }), + constraints.end()); + }; // 0) collect constrained indices of the current object IndexSet constrained_indices(locally_owned_dofs.size()); @@ -639,7 +631,11 @@ AffineConstraints::close() return; // sort the lines - std::sort(lines.begin(), lines.end()); + std::sort(lines.begin(), + lines.end(), + [](const ConstraintLine &l1, const ConstraintLine &l2) { + return l1.index < l2.index; + }); // update list of pointers and give the vector a sharp size since we // won't modify the size any more after this point.