#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:
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);
{
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.
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() +
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)
{
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>(
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,
// 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
// 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
// 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());
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);
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;
{
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
{
Assert(dim > 1, ExcNotImplemented());
// radius
- if DEAL_II_CONSTEXPR_IN_CONDITIONAL (dim > 1)
+ if constexpr (dim > 1)
{
scoord[0] = position.norm();
// azimuth angle \theta:
}
// 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())
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
}
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];