From: Matthias Maier Date: Fri, 6 Sep 2019 00:18:13 +0000 (-0500) Subject: Add a static_assert X-Git-Tag: v9.2.0-rc1~1136^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89ca962317ad845c3ffe126554c710f1962c75de;p=dealii.git Add a static_assert --- diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h index 4c9ae69d84..bdf6a13ee3 100644 --- a/include/deal.II/base/utilities.h +++ b/include/deal.II/base/utilities.h @@ -1032,13 +1032,18 @@ namespace Utilities inline T fixed_power(const T x) { + static_assert( + !std::is_integral::value || (N >= 0), + "The non-type template parameter N must be a non-negative integer for integral type T"); + if (N == 0) return T(1.); else if (N < 0) return T(1.) / fixed_power<-N>(x); else // Use exponentiation by squaring: - return ((N % 2 == 1) ? x * fixed_power(x * x) : fixed_power(x * x)); + return ((N % 2 == 1) ? x * fixed_power(x * x) : + fixed_power(x * x)); }