From af9f89b29f3c482c0444037d35b5bd4323fe3122 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 30 Jun 2023 13:15:40 -0600 Subject: [PATCH] Simplify constructors/operators of AffineConstraints::ConstraintLine. --- include/deal.II/lac/affine_constraints.h | 57 +++++++++--------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index dc01b2cc46..7c9ede0d16 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -1658,15 +1658,24 @@ public: /** * Copy constructor. */ - template - ConstraintLine(const ConstraintLineType &other); + ConstraintLine(const ConstraintLine &other) = default; + + /** + * Move constructor. + */ + ConstraintLine(ConstraintLine &&other) noexcept = default; /** * Copy assignment. */ - template ConstraintLine & - operator=(const ConstraintLineType &other); + operator=(const ConstraintLine &other) = default; + + /** + * Move assignment. + */ + ConstraintLine & + operator=(ConstraintLine &&other) noexcept = default; /** * This operator is a bit weird and unintuitive: it compares the line @@ -2451,7 +2460,14 @@ AffineConstraints::copy_from( const AffineConstraints &other) { lines.clear(); - lines.insert(lines.begin(), other.lines.begin(), other.lines.end()); + lines.reserve(other.lines.size()); + + for (const auto l : other.lines) + lines.emplace_back(l.index, + typename ConstraintLine::Entries(l.entries.begin(), + l.entries.end()), + l.inhomogeneity); + lines_cache = other.lines_cache; local_lines = other.local_lines; sorted = other.sorted; @@ -2523,37 +2539,6 @@ inline AffineConstraints::ConstraintLine::ConstraintLine( -template -template -inline AffineConstraints::ConstraintLine::ConstraintLine( - const ConstraintLineType &other) -{ - this->index = other.index; - - entries.clear(); - entries.insert(entries.begin(), other.entries.begin(), other.entries.end()); - - this->inhomogeneity = other.inhomogeneity; -} - - - -template -template -inline typename AffineConstraints::ConstraintLine & -AffineConstraints::ConstraintLine::operator=( - const ConstraintLineType &other) -{ - this->index = other.index; - - entries.clear(); - entries.insert(entries.begin(), other.entries.begin(), other.entries.end()); - - this->inhomogeneity = other.inhomogeneity; - - return *this; -} - DEAL_II_NAMESPACE_CLOSE #endif -- 2.39.5