]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify constructors/operators of AffineConstraints::ConstraintLine.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 30 Jun 2023 19:15:40 +0000 (13:15 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 1 Jul 2023 03:54:32 +0000 (21:54 -0600)
include/deal.II/lac/affine_constraints.h

index dc01b2cc468b437d601342da7f1b9c6bc1a38a52..7c9ede0d16b50e49885df36baa5416c3c2f01b4a 100644 (file)
@@ -1658,15 +1658,24 @@ public:
     /**
      * Copy constructor.
      */
-    template <typename ConstraintLineType>
-    ConstraintLine(const ConstraintLineType &other);
+    ConstraintLine(const ConstraintLine &other) = default;
+
+    /**
+     * Move constructor.
+     */
+    ConstraintLine(ConstraintLine &&other) noexcept = default;
 
     /**
      * Copy assignment.
      */
-    template <typename ConstraintLineType>
     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<number>::copy_from(
   const AffineConstraints<other_number> &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<number>::ConstraintLine::ConstraintLine(
 
 
 
-template <typename number>
-template <typename ConstraintLineType>
-inline AffineConstraints<number>::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 <typename number>
-template <typename ConstraintLineType>
-inline typename AffineConstraints<number>::ConstraintLine &
-AffineConstraints<number>::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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.