]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make an exception text readable. 12442/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 11 Jun 2021 14:04:12 +0000 (08:04 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 11 Jun 2021 15:15:56 +0000 (09:15 -0600)
include/deal.II/base/exceptions.h

index 5bdeacd668cd421dcbb4350ec28f5b51ed7ac68d..d5dd3e3962874f778b5ed776466a9a73a1154ff4 100644 (file)
@@ -1599,6 +1599,27 @@ namespace deal_II_exceptions
     }
 #endif /*ifdef DEAL_II_HAVE_BUILTIN_EXPECT*/
 
+
+namespace deal_II_exceptions
+{
+  namespace internals
+  {
+    /**
+     * A function that compares two values for equality, after converting to a
+     * common type to avoid compiler warnings when comparing objects of
+     * different types (e.g., unsigned and signed variables).
+     */
+    template <typename T, typename U>
+    inline bool
+    compare_for_equality(const T &dim1, const U &dim2)
+    {
+      using common_type = typename std::common_type<T, U>::type;
+      return static_cast<common_type>(dim1) == static_cast<common_type>(dim2);
+    }
+  } // namespace internals
+} // namespace deal_II_exceptions
+
+
 /**
  * Special assertion for dimension mismatch.
  *
@@ -1619,13 +1640,9 @@ namespace deal_II_exceptions
  *
  * @ingroup Exceptions
  */
-#define AssertDimension(dim1, dim2)                                            \
-  Assert(static_cast<typename ::dealii::internal::argument_type<void(          \
-             typename std::common_type<decltype(dim1),                         \
-                                       decltype(dim2)>::type)>::type>(dim1) == \
-           static_cast<typename ::dealii::internal::argument_type<void(        \
-             typename std::common_type<decltype(dim1),                         \
-                                       decltype(dim2)>::type)>::type>(dim2),   \
+#define AssertDimension(dim1, dim2)                                           \
+  Assert(::dealii::deal_II_exceptions::internals::compare_for_equality(dim1,  \
+                                                                       dim2), \
          dealii::ExcDimensionMismatch((dim1), (dim2)))
 
 
@@ -1661,6 +1678,7 @@ namespace internal
   // https://stackoverflow.com/questions/13842468/comma-in-c-c-macro
   template <typename T>
   struct argument_type;
+
   template <typename T, typename U>
   struct argument_type<T(U)>
   {

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.