From e0f4c56fd7dc613da14b1c3a1c59722ec01d3cbb Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Thu, 5 Mar 2020 18:56:08 +0100
Subject: [PATCH] [typetraits/utility] Add functions to create integer sequence
 with offset

---
 dumux/common/typetraits/utility.hh | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/dumux/common/typetraits/utility.hh b/dumux/common/typetraits/utility.hh
index 5c70972143..20d69bb102 100644
--- a/dumux/common/typetraits/utility.hh
+++ b/dumux/common/typetraits/utility.hh
@@ -70,6 +70,34 @@ template <std::size_t n, std::size_t e>
 using makeIncompleteIntegerSequence =
         typename Detail::ConcatSeq<decltype(std::make_index_sequence<e>{}), e + 1, decltype(std::make_index_sequence<(n > e) ? (n - e - 1) : 0>{})>::type;
 
+/*
+ * \ingroup TypeTraits
+ * \brief add an offset to an index sequence
+ * \tparam offset the offset
+ * \tparam is the index sequence
+ *
+ * see https://stackoverflow.com/a/35625414
+ */
+template <std::size_t offset, std::size_t ... is>
+constexpr std::index_sequence<(offset + is)...> addOffsetToIndexSequence(std::index_sequence<is...>)
+{ return {}; }
+
+/*
+ * \ingroup TypeTraits
+ * \brief create an index sequence starting from an offset
+ * \tparam offset the offset
+ * \tparam n the length of the sequence
+ *
+ * example: makeIndexSequenceWithOffset<2, 3> = [2,3,4]
+ *
+ * see https://stackoverflow.com/a/35625414
+ */
+template <std::size_t offset, std::size_t n>
+constexpr auto makeIndexSequenceWithOffset()
+{
+    return addOffsetToIndexSequence<offset>(std::make_index_sequence<n>{});
+}
+
 } // end namespace Dumux
 
 #endif
-- 
GitLab