]> https://gitweb.dealii.org/ - dealii.git/commitdiff
ScalarPolynomialsBase: remove some reinterpret_casts.
authorDavid Wells <drwells@email.unc.edu>
Tue, 13 Aug 2024 22:18:21 +0000 (16:18 -0600)
committerDavid Wells <drwells@email.unc.edu>
Wed, 14 Aug 2024 03:52:04 +0000 (21:52 -0600)
include/deal.II/base/scalar_polynomials_base.h

index 34ab391dabd3e7e9ee3970a36693cf2991bb5612..1c96466fa505a77a366897c5d36f53498cb458d4 100644 (file)
@@ -258,29 +258,27 @@ inline Tensor<order, dim>
 ScalarPolynomialsBase<dim>::compute_derivative(const unsigned int i,
                                                const Point<dim>  &p) const
 {
-  if (order == 1)
+  if constexpr (order == 1)
     {
-      auto derivative = compute_1st_derivative(i, p);
-      return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
+      return compute_1st_derivative(i, p);
     }
-  if (order == 2)
+  else if constexpr (order == 2)
     {
-      auto derivative = compute_2nd_derivative(i, p);
-      return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
+      return compute_2nd_derivative(i, p);
     }
-  if (order == 3)
+  else if constexpr (order == 3)
     {
-      auto derivative = compute_3rd_derivative(i, p);
-      return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
+      return compute_3rd_derivative(i, p);
     }
-  if (order == 4)
+  else if constexpr (order == 4)
     {
-      auto derivative = compute_4th_derivative(i, p);
-      return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
+      return compute_4th_derivative(i, p);
+    }
+  else
+    {
+      DEAL_II_NOT_IMPLEMENTED();
+      return {};
     }
-  DEAL_II_NOT_IMPLEMENTED();
-  Tensor<order, dim> empty;
-  return empty;
 }
 
 DEAL_II_NAMESPACE_CLOSE

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.