From: Wolfgang Bangerth Date: Wed, 8 Feb 2023 20:42:37 +0000 (-0700) Subject: Fix an assertion. X-Git-Tag: v9.5.0-rc1~570^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f18f24d7b8a206ff3089adce9392abc52ed2efa8;p=dealii.git Fix an assertion. --- diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index ef8f22e2cb..87811ad57b 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -968,17 +968,20 @@ namespace Utilities inline T fixed_power(const T x) { - Assert( - !std::is_integral::value || (N >= 0), - ExcMessage( - "The non-type template parameter N must be a non-negative integer for integral type T")); + Assert(((std::is_integral::value == true) && (N >= 0)) || + (std::is_integral::value == false), + ExcMessage("If the type of the argument, T, is an integer type, " + "then the exponent N must be a non-negative integer " + "because the result would otherwise not be an integer.")); if (N == 0) return T(1.); else if (N < 0) + // For negative exponents, turn things into a positive exponent return T(1.) / fixed_power<-N>(x); else - // Use exponentiation by squaring: + // If we get here, we have a positive exponent. Compute the result + // by repeated squaring: return ((N % 2 == 1) ? x * fixed_power(x * x) : fixed_power(x * x)); }