Skip to content
Snippets Groups Projects
Commit 6951f8a7 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Merge branch 'feature/simplify-foreach' into 'master'

Short circuit Hybrid::forEach for integer_sequence

This reduced the template instanciation depth drastically.
E.g., for range=`integer_sequence<21>` is changed from 319 to 84.

This is especially important for clang, because this has a default max-depth of 256 in contrast to gcc (900).

See merge request !162
parents 01c9b3bd 3dabf46e
No related branches found
No related tags found
No related merge requests found
......@@ -262,6 +262,13 @@ namespace Impl {
evaluateFoldExpression<int>({(f(Hybrid::elementAt(range, std::integral_constant<Index,i>())), 0)...});
}
template<class F, class Index, Index... i>
constexpr void forEach(std::integer_sequence<Index, i...> range, F&& f, PriorityTag<2>)
{
evaluateFoldExpression<int>({(f(std::integral_constant<Index,i>()), 0)...});
}
template<class Range, class F,
std::enable_if_t<IsIntegralConstant<decltype(Hybrid::size(std::declval<Range>()))>::value, int> = 0>
constexpr void forEach(Range&& range, F&& f, PriorityTag<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