From: Wolfgang Bangerth Date: Tue, 1 Mar 2022 21:22:59 +0000 (-0700) Subject: Provide a template variable that can be used to query whether a type is an MPI type. X-Git-Tag: v9.4.0-rc1~411^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c34a6a5ff4f170956f6178167a8c34c0233115d;p=dealii.git Provide a template variable that can be used to query whether a type is an MPI type. --- diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 2a42571c7c..bf34814a3a 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -22,9 +22,11 @@ #include #include #include +#include #include +#include #include #include #include @@ -139,6 +141,36 @@ namespace Utilities */ namespace MPI { + /** + * A template variable that is `true` if the template argument `T` is a data + * type that is natively supported by MPI, and `false` otherwise. This + * variable can be used together with `std::enable_if` to selectively allow + * template functions only for those data types for which the template type + * is supported by MPI. The variable is, in essence, a concept in the sense + * of C++20. + */ + template + constexpr bool is_mpi_type = is_same_as_any_of, + std::complex, + std::complex, + wchar_t>::value; + /** * Return the number of MPI processes there exist in the given * @ref GlossMPICommunicator "communicator"