7 #include <dune/common/version.hh> 8 #include <dune/common/std/apply.hh> 9 #include <dune/typetree/treepath.hh> 10 #include <dune/typetree/typetraits.hh> 12 #include <amdis/common/Logical.hpp> 16 using RootTreePath = Dune::TypeTree::HybridTreePath<>;
26 template <
class Index>
28 : std::is_integral<Index>
31 template <
class Index, Index I>
33 : std::is_integral<Index>
36 template <
class Index, Index... I>
38 : std::is_integral<Index>
43 : std::conjunction<std::is_integral<Indices>...>
60 template <
class Index,
61 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
62 std::size_t treePathIndex(Index i)
64 return std::size_t(i);
67 template <
class Index, Index i,
68 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
69 auto treePathIndex(std::integral_constant<Index,i>)
71 return std::integral_constant<std::size_t,std::size_t(i)>{};
100 template <
class PreTreePath>
101 auto makeTreePath(PreTreePath tp);
106 auto makeTreePath(
Indices... ii)
107 -> decltype( Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...) )
109 return Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...);
112 inline auto makeTreePath()
114 return Dune::TypeTree::hybridTreePath();
117 template <
class Index, Index... I>
118 auto makeTreePath(std::integer_sequence<Index, I...>)
120 return makeTreePath(std::integral_constant<std::size_t, std::size_t(I)>{}...);
123 template <
class... T>
124 auto makeTreePath(std::tuple<T...>
const& tp)
126 return std::apply([](
auto... ii) {
return makeTreePath(ii...); }, tp);
129 template <
class... T>
130 auto const& makeTreePath(Dune::TypeTree::HybridTreePath<T...>
const& tp)
135 #if DUNE_VERSION_LT(DUNE_TYPETREE,2,7) 136 template <std::size_t... I>
137 auto makeTreePath(Dune::TypeTree::TreePath<I...>)
139 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t, I>{}...);
142 template <std::size_t... I>
143 auto makeTreePath(Dune::TypeTree::StaticTreePath<I...>)
145 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t, I>{}...);
154 template <
class TreePath, std::size_t... I>
155 void printTreePath(std::ostream& os, TreePath
const& tp, std::index_sequence<I...>)
157 (void)std::initializer_list<int>{
158 ((void)(os << treePathIndex(tp, std::integral_constant<std::size_t, I>{}) <<
","), 0)...
163 template <
class T0,
class... T>
164 std::string to_string(Dune::TypeTree::HybridTreePath<T0,T...>
const& tp)
166 std::stringstream ss;
167 Impl::printTreePath(ss, tp, std::make_index_sequence<
sizeof...(T)>{});
168 ss << Dune::TypeTree::treePathEntry<
sizeof...(T)>(tp);
172 inline std::string to_string(Dune::TypeTree::HybridTreePath<>
const&)
179 template <
class TreePath, std::size_t... I>
180 std::array<std::size_t,
sizeof...(I)> toArrayImpl(TreePath
const& tp, std::index_sequence<I...>)
182 return {{std::size_t(Dune::TypeTree::treePathEntry<I>(tp))...}};
186 template <
class T0,
class... T>
187 auto to_array(Dune::TypeTree::HybridTreePath<T0,T...>
const& tp)
189 return Impl::toArrayImpl(tp, std::make_index_sequence<1+
sizeof...(T)>{});
192 inline std::array<std::size_t,1> to_array(Dune::TypeTree::HybridTreePath<>
const&)
200 template <
class TreePath, std::size_t... I>
201 auto popFrontImpl(TreePath
const& tp, std::index_sequence<I...>)
203 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<I+1>(tp)...);
206 template <
class TreePath, std::size_t... I>
207 auto popBackImpl(TreePath
const& tp, std::index_sequence<I...>)
209 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<I>(tp)...);
213 template <
class T0,
class... T>
214 Dune::TypeTree::HybridTreePath<T...> pop_front(Dune::TypeTree::HybridTreePath<T0,T...>
const& tp)
216 return Impl::popFrontImpl(tp, std::make_index_sequence<
sizeof...(T)>{});
219 template <
class... T,
class TN>
220 Dune::TypeTree::HybridTreePath<T...> pop_front(Dune::TypeTree::HybridTreePath<T...,TN>
const& tp)
222 return Impl::popBackImpl(tp, std::make_index_sequence<
sizeof...(T)>{});
225 template <
class... S,
class... T>
226 Dune::TypeTree::HybridTreePath<S...,T...> cat(Dune::TypeTree::HybridTreePath<S...>
const& tp0,
227 Dune::TypeTree::HybridTreePath<T...>
const& tp1)
229 return Dune::TypeTree::HybridTreePath<S...,T...>(std::tuple_cat(tp0._data,tp1._data));
std::index_sequence< I... > Indices
class that represents a sequence of indices
Definition: Index.hpp:40
Definition: FieldMatVec.hpp:12
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: TreePath.hpp:27
std::integral_constant< bool, B > bool_t
A wrapper for bool types.
Definition: Logical.hpp:12