]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Only overload complex-valued operators if T!=U. 18121/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 11 Feb 2025 18:13:16 +0000 (11:13 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 11 Feb 2025 18:13:16 +0000 (11:13 -0700)
include/deal.II/base/complex_overloads.h

index 93d44ea5bd503e44231c895da393bade81d168bb..0009637f65fa3ab6cce4a72ed6b5056e018e6453 100644 (file)
@@ -64,7 +64,8 @@ struct ProductType;
  */
 template <typename T, typename U>
 inline std::enable_if_t<
-  std::is_floating_point_v<T> && std::is_floating_point_v<U>,
+  std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
+    !std::is_same_v<T, U>,
   typename ProductType<std::complex<T>, std::complex<U>>::type>
 operator*(const std::complex<T> &left, const std::complex<U> &right)
 {
@@ -104,7 +105,8 @@ operator*(const std::complex<T> &left, const std::complex<U> &right)
  */
 template <typename T, typename U>
 inline std::enable_if_t<
-  std::is_floating_point_v<T> && std::is_floating_point_v<U>,
+  std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
+    !std::is_same_v<T, U>,
   typename ProductType<std::complex<T>, std::complex<U>>::type>
 operator/(const std::complex<T> &left, const std::complex<U> &right)
 {
@@ -144,7 +146,7 @@ operator/(const std::complex<T> &left, const std::complex<U> &right)
  */
 template <typename T, typename U>
 inline std::enable_if_t<std::is_floating_point_v<T> &&
-                          std::is_floating_point_v<U>,
+                          std::is_floating_point_v<U> && !std::is_same_v<T, U>,
                         typename ProductType<std::complex<T>, U>::type>
 operator*(const std::complex<T> &left, const U &right)
 {
@@ -183,7 +185,7 @@ operator*(const std::complex<T> &left, const U &right)
  */
 template <typename T, typename U>
 inline std::enable_if_t<std::is_floating_point_v<T> &&
-                          std::is_floating_point_v<U>,
+                          std::is_floating_point_v<U> && !std::is_same_v<T, U>,
                         typename ProductType<std::complex<T>, U>::type>
 operator/(const std::complex<T> &left, const U &right)
 {
@@ -222,7 +224,7 @@ operator/(const std::complex<T> &left, const U &right)
  */
 template <typename T, typename U>
 inline std::enable_if_t<std::is_floating_point_v<T> &&
-                          std::is_floating_point_v<U>,
+                          std::is_floating_point_v<U> && !std::is_same_v<T, U>,
                         typename ProductType<T, std::complex<U>>::type>
 operator*(const T &left, const std::complex<U> &right)
 {
@@ -261,7 +263,7 @@ operator*(const T &left, const std::complex<U> &right)
  */
 template <typename T, typename U>
 inline std::enable_if_t<std::is_floating_point_v<T> &&
-                          std::is_floating_point_v<U>,
+                          std::is_floating_point_v<U> && !std::is_same_v<T, U>,
                         typename ProductType<T, std::complex<U>>::type>
 operator/(const T &left, const std::complex<U> &right)
 {

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.