8#include <dune/common/typetree/treepath.hh>
10#include <amdis/common/Apply.hpp>
11#include <amdis/common/ConceptsBase.hpp>
12#include <amdis/common/Literals.hpp>
13#include <amdis/common/Logical.hpp>
17using RootTreePath = Dune::TypeTree::TreePath<>;
27 template <
class Index>
29 : std::is_integral<Index>
32 template <
class Index, Index I>
34 : std::is_integral<Index>
37 template <
class Index, Index... I>
39 : std::is_integral<Index>
42 template <
class... Indices>
44 : std::conjunction<std::is_integral<Indices>...>
52 template <
class... Indices>
53 struct IsTreePath<Dune::TypeTree::TreePath<Indices...>>
60constexpr bool PreTreePath = Definition::IsTreePath<TP>::value || Definition::IsPreTreePath<TP>::value;
63using PreTreePath_t = bool_t<PreTreePath<TP>>;
71 template <
class Index,
72 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
73 constexpr std::size_t treePathIndex(Index i)
75 return std::size_t(i);
78 template <
class Index, Index i,
79 std::enable_if_t<std::is_integral_v<Index>,
int> = 0>
80 constexpr auto treePathIndex(std::integral_constant<Index,i>)
82 return std::integral_constant<std::size_t,std::size_t(i)>{};
111template <
class PreTreePath>
112constexpr auto makeTreePath(PreTreePath tp);
116template <
class... Indices>
117constexpr auto makeTreePath(Indices... ii)
118 ->
decltype( Dune::TypeTree::treePath(Impl::treePathIndex(ii)...) )
120 return Dune::TypeTree::treePath(Impl::treePathIndex(ii)...);
123constexpr auto makeTreePath()
125 return Dune::TypeTree::treePath();
128template <
class Index, Index... I>
129constexpr auto makeTreePath(std::integer_sequence<Index, I...>)
131 return makeTreePath(std::integral_constant<std::size_t, std::size_t(I)>{}...);
135constexpr auto makeTreePath(std::tuple<T...>
const& tp)
137 return std::apply([](
auto... ii) {
return makeTreePath(ii...); }, tp);
141constexpr auto const& makeTreePath(Dune::TypeTree::TreePath<T...>
const& tp)
146template <std::size_t... I>
147constexpr auto makeTreePath(Dune::TypeTree::TreePath<Dune::index_constant<I>...> tp)
156template <
char... digits>
157constexpr auto operator"" _tp()
159 return Dune::TypeTree::treePath(std::integral_constant<std::size_t,Impl::char2digit(digits)>{}...);
165std::string to_string(Dune::TypeTree::TreePath<T...>
const& tp)
167 auto entry = [&](
auto i) {
return std::to_string(std::size_t(tp[i])); };
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)));
175inline std::string to_string(Dune::TypeTree::TreePath<>
const&)
182auto to_array(Dune::TypeTree::TreePath<T...>
const& tp)
184 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
185 return std::array<std::size_t,
sizeof...(T)>{std::size_t(tp[i])...};
190template <
class T0,
class... T>
191auto pop_front(Dune::TypeTree::TreePath<T0,T...>
const& tp)
193 return Ranges::applyIndices<
sizeof...(T)>([&](
auto... i) {
194 return Dune::TypeTree::treePath(tp[index_t<i+1>{}]...);
200requires (
sizeof...(T)>0)
201auto pop_back(Dune::TypeTree::TreePath<T...>
const& tp)
203 return Ranges::applyIndices<
sizeof...(T)-1>([&](
auto... i) {
204 return Dune::TypeTree::treePath(tp[i]...);
209template <
class... S,
class... T>
210auto cat(Dune::TypeTree::TreePath<S...>
const& tp0, Dune::TypeTree::TreePath<T...>
const& tp1)
212 return Dune::TypeTree::join(tp0, tp1);
215template<
class First,
class Second, REQUIRES(Concepts::PreTreePath<First> and Concepts::PreTreePath<Second>)>
216auto cat(First
const& first, Second
const& second)
218 return cat(makeTreePath(first), makeTreePath(second));
Definition TreePath.hpp:30
Definition TreePath.hpp:50