From: David Wells Date: Fri, 24 Mar 2023 12:54:04 +0000 (-0400) Subject: Be more correct in our noexcept usage. X-Git-Tag: v9.5.0-rc1~417^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14970%2Fhead;p=dealii.git Be more correct in our noexcept usage. --- diff --git a/include/deal.II/lac/trilinos_vector.h b/include/deal.II/lac/trilinos_vector.h index 5b2d87426c..0a88440e15 100644 --- a/include/deal.II/lac/trilinos_vector.h +++ b/include/deal.II/lac/trilinos_vector.h @@ -500,8 +500,12 @@ namespace TrilinosWrappers /** * Move constructor. Creates a new vector by stealing the internal data * of the vector @p v. + * + * @note In order for this constructor to leave the moved-from object in a + * valid state it must allocate memory (in this case, an empty + * Epetra_FEVector) - hence it cannot be marked as noexcept. */ - Vector(Vector &&v) noexcept; + Vector(Vector &&v); // NOLINT /** * Destructor. diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index 1f8224118a..6ad4335026 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -98,10 +98,11 @@ namespace TrilinosWrappers - Vector::Vector(Vector &&v) noexcept + Vector::Vector(Vector &&v) // NOLINT : Vector() { // initialize a minimal, valid object and swap + static_cast(*this) = static_cast(v); swap(v); } @@ -499,6 +500,7 @@ namespace TrilinosWrappers Vector & Vector::operator=(Vector &&v) noexcept { + static_cast(*this) = static_cast(v); swap(v); return *this; }