From 89ca962317ad845c3ffe126554c710f1962c75de Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 5 Sep 2019 19:18:13 -0500 Subject: [PATCH] Add a static_assert --- include/deal.II/base/utilities.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)); } -- 2.39.5