From 93f0b2bd319b14532188602477c7601c89c1f254 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Tue, 21 Jul 2020 09:36:51 +0200
Subject: [PATCH] [common][partial] Add MTBV containing const references

---
 dumux/common/partial.hh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dumux/common/partial.hh b/dumux/common/partial.hh
index 1dc4dbeabd..eeb65a35a8 100644
--- a/dumux/common/partial.hh
+++ b/dumux/common/partial.hh
@@ -42,6 +42,17 @@ auto partial(Dune::MultiTypeBlockVector<Args...>& v, Dune::index_constant<i>...
     return Dune::MultiTypeBlockVector<std::add_lvalue_reference_t<std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(v[indices]...);
 }
 
+/*!
+ * \brief a function to get a MultiTypeBlockVector with const references to some entries of another MultiTypeBlockVector
+ * \param v a MultiTypeBlockVector
+ * \param indices the indices of the entries that should be referenced
+ */
+template<class ...Args, std::size_t ...i>
+auto partial(const Dune::MultiTypeBlockVector<Args...>& v, Dune::index_constant<i>... indices)
+{
+    return Dune::MultiTypeBlockVector<std::add_lvalue_reference_t<const std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(v[indices]...);
+}
+
 /*!
  * \brief a function to get a tuple with references to some entries of another tuple
  * \param v a tuple
@@ -53,6 +64,17 @@ auto partial(std::tuple<Args...>& v, Dune::index_constant<i>... indices)
     return std::tuple<std::add_lvalue_reference_t<std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(std::get<indices>(v)...);
 }
 
+/*!
+ * \brief a function to get a tuple with const references to some entries of another tuple
+ * \param v a tuple
+ * \param indices a tuple of indices of the entries that should be referenced
+ */
+template<class ...Args, std::size_t ...i>
+auto partial(const std::tuple<Args...>& v, Dune::index_constant<i>... indices)
+{
+    return std::tuple<std::add_lvalue_reference_t<const std::decay_t<std::tuple_element_t<indices, std::tuple<Args...>>>>...>(std::get<indices>(v)...);
+}
+
 /*!
  * \brief a function to get a MultiTypeBlockVector with references to some entries of another MultiTypeBlockVector
  * \param t an std::tuple or Dune::MultiTypeBlockVector
-- 
GitLab