Skip to content
Snippets Groups Projects
Commit ee9db7a5 authored by Timo Koch's avatar Timo Koch
Browse files

[math] Use integer type in Factorial and deprecate struct version (use factorial function)

Using an enum has the side effect that you can't do arithmetic without explicitly casting to an integer type.
This also produced a compiler warning with clang 10 "arithmetic between different enumeration types is deprecated"
-Wdeprecated-anon-enum-enum-conversion
parent a1e068a4
No related branches found
No related tags found
1 merge request!1045[math] Use integer type in Factorial
Pipeline #41048 passed with warnings
......@@ -2,6 +2,8 @@
- Add `pragma omp simd` annotations in the LoopSIMD class to improve compiler optimizations
- deprecate Factorial in common/math.hh (use factorial function)
## Build System
- Remove the variable `DUNE_DEFAULT_LIBS`
......@@ -21,7 +23,6 @@
- Remove deprecated cmake function overload `target_link_libraries`
# Release 2.8
- Set minimal required CMake version in cmake to >= 3.13.
......
......@@ -86,19 +86,20 @@ namespace Dune
}
//! Calculates the factorial of m at compile time
//! \deprecated Will be removed after release 2.9
template <int m>
struct Factorial
{
//! factorial stores m!
enum { factorial = m * Factorial<m-1>::factorial };
static constexpr int factorial = m * Factorial<m-1>::factorial;
};
//! end of recursion of factorial via specialization
template <>
struct Factorial<0>
struct [[deprecated("Use function factorial instead! Will be removed after Dune 2.9")]] Factorial<0>
{
// 0! = 1
enum { factorial = 1 };
static constexpr int factorial = 1;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment