8#include <dune/common/version.hh>
9#include <dune/typetree/treepath.hh>
10#include <dune/typetree/typetraits.hh>
12#include <amdis/common/Apply.hpp>
13#include <amdis/common/Literals.hpp>
14#include <amdis/common/Logical.hpp>
18using RootTreePath = Dune::TypeTree::HybridTreePath<>;
28 template <
class Index>
30 : std::is_integral<Index>
33 template <
class Index, Index I>
35 : std::is_integral<Index>
38 template <
class Index, Index... I>
40 : std::is_integral<Index>
43 template <
class... Indices>
45 : std::conjunction<std::is_integral<Indices>...>
54using PreTreePath_t = bool_t<PreTreePath<TP>>;
62 template <
class Index,
63 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
64 constexpr std::size_t treePathIndex(Index i)
66 return std::size_t(i);
69 template <
class Index, Index i,
70 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
71 constexpr auto treePathIndex(std::integral_constant<Index,i>)
73 return std::integral_constant<std::size_t,std::size_t(i)>{};
102template <
class PreTreePath>
103constexpr auto makeTreePath(PreTreePath tp);
107template <
class... Indices>
108constexpr auto makeTreePath(Indices... ii)
109 ->
decltype( Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...) )
111 return Dune::TypeTree::hybridTreePath(Impl::treePathIndex(ii)...);
114constexpr auto makeTreePath()
116 return Dune::TypeTree::hybridTreePath();
119template <
class Index, Index... I>
120constexpr auto makeTreePath(std::integer_sequence<Index, I...>)
122 return makeTreePath(std::integral_constant<std::size_t, std::size_t(I)>{}...);
126constexpr auto makeTreePath(std::tuple<T...>
const& tp)
128 return std::apply([](
auto... ii) {
return makeTreePath(ii...); }, tp);
132constexpr auto const& makeTreePath(Dune::TypeTree::HybridTreePath<T...>
const& tp)
137template <std::size_t... I>
138constexpr auto makeTreePath(Dune::TypeTree::StaticTreePath<I...>)
140 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t, I>{}...);
147template <
char... digits>
148constexpr auto operator"" _tp()
150 return Dune::TypeTree::hybridTreePath(std::integral_constant<std::size_t,Impl::char2digit(digits)>{}...);
156std::string to_string(Dune::TypeTree::HybridTreePath<T...>
const& tp)
158 auto entry = [&](
auto i) {
return std::to_string(std::size_t(Dune::TypeTree::treePathEntry<i>(tp))); };
159 auto first = [&] {
return entry(std::integral_constant<std::size_t,0>()); };
161 return Ranges::applyIndices<1,
sizeof...(T)>([&](
auto... i) -> std::string {
162 return (first() +...+ (
"," + entry(i)));
166inline std::string to_string(Dune::TypeTree::HybridTreePath<>
const&)
173auto to_array(Dune::TypeTree::HybridTreePath<T...>
const& tp)
175 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
176 return std::array<std::size_t,
sizeof...(T)>{std::size_t(Dune::TypeTree::treePathEntry<i>(tp))...};
181template <
class T0,
class... T>
182auto pop_front(Dune::TypeTree::HybridTreePath<T0,T...>
const& tp)
184 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
185 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<i+1>(tp)...);
190template <
class... T,
class TN>
191auto pop_back(Dune::TypeTree::HybridTreePath<T...,TN>
const& tp)
193 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
194 return Dune::TypeTree::hybridTreePath(Dune::TypeTree::treePathEntry<i>(tp)...);
199template <
class... S,
class... T>
200auto cat(Dune::TypeTree::HybridTreePath<S...>
const& tp0, Dune::TypeTree::HybridTreePath<T...>
const& tp1)
202 return Dune::TypeTree::HybridTreePath<S...,T...>(std::tuple_cat(tp0._data,tp1._data));
Definition: TreePath.hpp:31