8 #include <dune/common/version.hh> 9 #include <dune/common/std/apply.hh> 10 #include <dune/typetree/treepath.hh> 11 #include <dune/typetree/typetraits.hh> 13 #include <amdis/common/Apply.hpp> 14 #include <amdis/common/Literals.hpp> 15 #include <amdis/common/Logical.hpp> 19 using RootTreePath = Dune::TypeTree::HybridTreePath<>;
29 template <
class Index>
31 : std::is_integral<Index>
34 template <
class Index, Index I>
36 : std::is_integral<Index>
39 template <
class Index, Index... I>
41 : std::is_integral<Index>
46 : std::conjunction<std::is_integral<Indices>...>
63 template <
class Index,
64 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
65 std::size_t treePathIndex(Index i)
67 return std::size_t(i);
70 template <
class Index, Index i,
71 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
72 auto treePathIndex(std::integral_constant<Index,i>)
74 return std::integral_constant<std::size_t,std::size_t(i)>{};
103 template <
class PreTreePath>
104 auto makeTreePath(PreTreePath tp);
109 auto makeTreePath(
Indices... ii)
110 -> decltype( Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...) )
112 return Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...);
115 inline auto makeTreePath()
117 return Dune::TypeTree::hybridTreePath();
120 template <
class Index, Index... I>
121 auto makeTreePath(std::integer_sequence<Index, I...>)
123 return makeTreePath(std::integral_constant<std::size_t, std::size_t(I)>{}...);
126 template <
class... T>
127 auto makeTreePath(std::tuple<T...>
const& tp)
129 return std::apply([](
auto... ii) {
return makeTreePath(ii...); }, tp);
132 template <
class... T>
133 auto const& makeTreePath(Dune::TypeTree::HybridTreePath<T...>
const& tp)
138 #if DUNE_VERSION_LT(DUNE_TYPETREE,2,7) 139 template <std::size_t... I>
140 auto makeTreePath(Dune::TypeTree::TreePath<I...>)
142 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t, I>{}...);
145 template <std::size_t... I>
146 auto makeTreePath(Dune::TypeTree::StaticTreePath<I...>)
148 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t, I>{}...);
156 template <
char... digits>
157 constexpr
auto operator"" _tp()
159 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t,Impl::char2digit(digits)>{}...);
164 template <
class... T>
165 std::string to_string(Dune::TypeTree::HybridTreePath<T...>
const& tp)
167 auto entry = [&](
auto i) {
return std::to_string(std::size_t(Dune::TypeTree::treePathEntry<i>(tp))); };
168 auto first = [&] {
return entry(std::integral_constant<std::size_t,0>()); };
170 return Ranges::applyIndices<1,
sizeof...(T)>([&](
auto... i) -> std::string {
171 return (first() +...+ (
"," + entry(i)));
175 inline std::string to_string(Dune::TypeTree::HybridTreePath<>
const&)
181 template <
class... T>
182 auto to_array(Dune::TypeTree::HybridTreePath<T...>
const& tp)
184 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
185 return std::array<std::size_t,
sizeof...(T)>{std::size_t(Dune::TypeTree::treePathEntry<i>(tp))...};
190 template <
class T0,
class... T>
191 auto pop_front(Dune::TypeTree::HybridTreePath<T0,T...>
const& tp)
193 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
194 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<i+1>(tp)...);
199 template <
class... T,
class TN>
200 auto pop_back(Dune::TypeTree::HybridTreePath<T...,TN>
const& tp)
202 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
203 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<i>(tp)...);
208 template <
class... S,
class... T>
209 auto cat(Dune::TypeTree::HybridTreePath<S...>
const& tp0, Dune::TypeTree::HybridTreePath<T...>
const& tp1)
211 return Dune::TypeTree::HybridTreePath<S...,T...>(std::tuple_cat(tp0._data,tp1._data));
auto pop_back(Dune::TypeTree::HybridTreePath< T..., TN > const &tp)
Extract the last entry in the treepath.
Definition: TreePath.hpp:200
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
auto cat(Dune::TypeTree::HybridTreePath< S... > const &tp0, Dune::TypeTree::HybridTreePath< T... > const &tp1)
Concatenate two treepaths.
Definition: TreePath.hpp:209
Definition: TreePath.hpp:30
auto pop_front(Dune::TypeTree::HybridTreePath< T0, T... > const &tp)
Extract the first entry in the treepath.
Definition: TreePath.hpp:191
std::integral_constant< bool, B > bool_t
A wrapper for bool types.
Definition: Logical.hpp:12