move Iterate<D>and Switch<D> to netgen utils

This commit is contained in:
Joachim Schoeberl 2023-03-05 14:53:03 +01:00
parent 3085fac973
commit 0ad5973101

View File

@ -168,6 +168,28 @@ namespace ngcore
return current; return current;
} }
template <int N> using IC = std::integral_constant<int,N>; // needed for Iterate
template <int NUM, typename FUNC>
NETGEN_INLINE void Iterate (FUNC f)
{
if constexpr (NUM > 1) Iterate<NUM-1> (f);
if constexpr (NUM >= 1) f(IC<NUM-1>());
}
template <int NUM, typename FUNC>
NETGEN_INLINE void Switch (size_t nr, FUNC f)
{
if (NUM-1 == nr) f(IC<NUM-1>());
if constexpr (NUM > 1) Switch<NUM-1> (nr, f);
}
namespace detail namespace detail
{ {
template<typename T> template<typename T>