]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clean up DEAL_II_CONSTEXPR_IN_CONDITIONAL
authorDaniel Arndt <arndtd@ornl.gov>
Sat, 1 Jul 2023 18:10:13 +0000 (14:10 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Sat, 1 Jul 2023 18:12:27 +0000 (14:12 -0400)
include/deal.II/base/config.h.in
include/deal.II/base/partitioner.templates.h
include/deal.II/base/utilities.h
include/deal.II/lac/sparse_matrix.templates.h
include/deal.II/lac/vector_operations_internal.h
source/base/geometric_utilities.cc
source/base/polynomials_rt_bubbles.cc

index 98ab0768ab9855136f36aae5cb11539060687d6d..b5da2f18561233ad0f302a08b91abd6b6913a435 100644 (file)
@@ -564,19 +564,6 @@ _Pragma("GCC diagnostic pop")
   #define DEAL_II_WARNING(desc) DEAL_II_DO_PRAGMA(message(#desc))
 #endif
 
-/***********************************************************************
- * Some places in deal.II require or benefit from using "if constexpr".
- * However, this feature is only available in C++17 and above.
- * The macro defined here can be used so that
- * "if DEAL_II_CONSTEXPR_IN_CONDITIONAL (...)" expands to "if constexpr(...)"
- * when C++17 is supported and to "if (...)" otherwise.
- */
-#ifdef DEAL_II_HAVE_CXX17
-  #define DEAL_II_CONSTEXPR_IN_CONDITIONAL constexpr
-#else
-  #define DEAL_II_CONSTEXPR_IN_CONDITIONAL
-#endif
-
 
 /***********************************************************************
  * Final inclusions:
index a048d75ba03e947d34e7421d4c77c306832f833f..1edc4b2b3ad4c8cbe1401106030c49c805942a62 100644 (file)
@@ -119,9 +119,8 @@ namespace Utilities
       for (unsigned int i = 0; i < n_import_targets; ++i)
         {
 #    if defined(DEAL_II_MPI_WITH_DEVICE_SUPPORT)
-          if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_same<
-                                                 MemorySpaceType,
-                                                 MemorySpace::Default>::value)
+          if constexpr (std::is_same<MemorySpaceType,
+                                     MemorySpace::Default>::value)
             {
               const auto chunk_size = import_indices_plain_dev[i].size();
               using IndexType       = decltype(chunk_size);
@@ -219,8 +218,8 @@ namespace Utilities
                 {
                   const unsigned int chunk_size =
                     ghost_range.second - ghost_range.first;
-                  if DEAL_II_CONSTEXPR_IN_CONDITIONAL (
-                    std::is_same<MemorySpaceType, MemorySpace::Host>::value)
+                  if constexpr (std::is_same<MemorySpaceType,
+                                             MemorySpace::Host>::value)
                     {
                       // If source and destination are overlapping, we must be
                       // careful to use an appropriate copy function.
@@ -391,8 +390,8 @@ namespace Utilities
                   if (ghost_array_ptr + offset !=
                       ghost_array.data() + my_ghosts->first)
                     {
-                      if DEAL_II_CONSTEXPR_IN_CONDITIONAL (
-                        std::is_same<MemorySpaceType, MemorySpace::Host>::value)
+                      if constexpr (std::is_same<MemorySpaceType,
+                                                 MemorySpace::Host>::value)
                         {
                           if (offset > my_ghosts->first)
                             std::copy_backward(ghost_array.data() +
@@ -597,9 +596,8 @@ namespace Utilities
 
           const Number *read_position = temporary_storage.data();
 #    if defined(DEAL_II_MPI_WITH_DEVICE_SUPPORT)
-          if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_same<
-                                                 MemorySpaceType,
-                                                 MemorySpace::Default>::value)
+          if constexpr (std::is_same<MemorySpaceType,
+                                     MemorySpace::Default>::value)
             {
               if (vector_operation == VectorOperation::add)
                 {
@@ -777,9 +775,8 @@ namespace Utilities
           Assert(ghost_array.begin() != nullptr, ExcInternalError());
 
 #    if defined(DEAL_II_MPI_WITH_DEVICE_SUPPORT)
-          if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_same<
-                                                 MemorySpaceType,
-                                                 MemorySpace::Default>::value)
+          if constexpr (std::is_same<MemorySpaceType,
+                                     MemorySpace::Default>::value)
             {
               Kokkos::deep_copy(
                 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>(
@@ -789,8 +786,7 @@ namespace Utilities
           else
 #    endif
             {
-              if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivial<
-                                                     Number>::value)
+              if constexpr (std::is_trivial<Number>::value)
                 {
                   std::memset(ghost_array.data(),
                               0,
index 6f2f1ae2a6fadc455838308f2744ec08df410704..35a7ea24f6dae28c965bf19f823b96ccfdd2b5ca 100644 (file)
@@ -1358,8 +1358,7 @@ namespace Utilities
     // see if the object is small and copyable via memcpy. if so, use
     // this fast path. otherwise, we have to go through the BOOST
     // serialization machinery
-    if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivially_copyable<T>() &&
-                                         sizeof(T) < 256)
+    if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
       {
         // Determine the size. There are places where we would like to use a
         // truly empty type, for which we use std::tuple<> (i.e., a tuple
@@ -1442,8 +1441,7 @@ namespace Utilities
     // see if the object is small and copyable via memcpy. if so, use
     // this fast path. otherwise, we have to go through the BOOST
     // serialization machinery
-    if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivially_copyable<T>() &&
-                                         sizeof(T) < 256)
+    if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
       {
         // Determine the size. There are places where we would like to use a
         // truly empty type, for which we use std::tuple<> (i.e., a tuple
@@ -1523,8 +1521,7 @@ namespace Utilities
     // see if the object is small and copyable via memcpy. if so, use
     // this fast path. otherwise, we have to go through the BOOST
     // serialization machinery
-    if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivially_copyable<T>() &&
-                                         sizeof(T) * N < 256)
+    if constexpr (std::is_trivially_copyable<T>() && sizeof(T) * N < 256)
       {
         Assert(std::distance(cbegin, cend) == sizeof(T) * N,
                ExcInternalError());
index a58d4667f5d474d87211b587f8871e1170676b2d..60662d2b59c1a925b27f12653b506054491125b7 100644 (file)
@@ -219,7 +219,7 @@ SparseMatrix<number>::operator=(const double d)
       grain_size);
   else if (matrix_size > 0)
     {
-      if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivial<number>::value)
+      if constexpr (std::is_trivial<number>::value)
         std::memset(val.get(), 0, matrix_size * sizeof(number));
       else
         std::fill(val.get(), val.get() + matrix_size, 0);
index e9788674b9e9ec1d9127274184722c6d5fe58dcd..47c90bde0af9d0397e53d5cf22f06ae876fc4447 100644 (file)
@@ -212,7 +212,7 @@ namespace internal
 
         if (value == Number())
           {
-            if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivial<Number>::value)
+            if constexpr (std::is_trivial<Number>::value)
               {
                 std::memset(dst + begin, 0, sizeof(Number) * (end - begin));
                 return;
@@ -241,10 +241,8 @@ namespace internal
       {
         Assert(end >= begin, ExcInternalError());
 
-        if DEAL_II_CONSTEXPR_IN_CONDITIONAL (std::is_trivially_copyable<
-                                               Number>() &&
-                                             std::is_same<Number,
-                                                          OtherNumber>::value)
+        if constexpr (std::is_trivially_copyable<Number>() &&
+                      std::is_same<Number, OtherNumber>::value)
           std::memcpy(dst + begin, src + begin, (end - begin) * sizeof(Number));
         else
           {
index 5455f32d9c394d734df6ca1f42edc47e3f8465b8..ee041f25817bce6b0c938d27c2b884916e5cd774 100644 (file)
@@ -50,7 +50,7 @@ namespace GeometricUtilities
       Assert(dim > 1, ExcNotImplemented());
 
       // radius
-      if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim > 1)
+      if constexpr (dim > 1)
         {
           scoord[0] = position.norm();
           // azimuth angle \theta:
@@ -61,7 +61,7 @@ namespace GeometricUtilities
         }
 
       // polar angle \phi:
-      if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim == 3)
+      if constexpr (dim == 3)
         {
           // acos returns the angle in the range [0,\pi]
           if (scoord[0] > std::numeric_limits<double>::min())
index 104b380a091626819799fb6690abfd7f7aaa1dcf..367040222c97edcb1f3ce81a900b17473f0f748a 100644 (file)
@@ -109,14 +109,14 @@ PolynomialsRT_Bubbles<dim>::evaluate(
   double             monoval_i[dim][n_derivatives + 1];
 
 
-  if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim <= 1)
+  if constexpr (dim <= 1)
     {
       (void)monoval_plus;
       (void)monoval_i;
     }
 
   unsigned int start = n_sub;
-  if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim == 2)
+  if constexpr (dim == 2)
     {
       // In 2d the curl part of the space is spanned by the vectors
       // of two types. The first one is
@@ -199,7 +199,7 @@ PolynomialsRT_Bubbles<dim>::evaluate(
         }
       Assert(start == this->n() - my_degree - 1, ExcInternalError());
     }
-  else if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim == 3)
+  else if constexpr (dim == 3)
     {
       double monoval[dim][n_derivatives + 1];
       double monoval_j[dim][n_derivatives + 1];

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.