From 3dabf46ec4ae427556e5eaef6f18389d04cb5b9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org>
Date: Sun, 13 Nov 2016 17:53:59 +0100
Subject: [PATCH] Short circuit Hybrid::forEach for integer_sequence

This reduced the template instanciation depth drastically.
For range=integer_sequence<21> is changes from 319 to 84.
---
 dune/common/hybridutilities.hh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dune/common/hybridutilities.hh b/dune/common/hybridutilities.hh
index 75b559825..db7b9c1b6 100644
--- a/dune/common/hybridutilities.hh
+++ b/dune/common/hybridutilities.hh
@@ -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>)
-- 
GitLab