Commit 420fc82d authored by Christian Engwer's avatar Christian Engwer

[!71] Make TreePath<i...> an alias for HybridTreePath<index_constant<i>...>

Merge branch 'feature/merge-treepath-classes' into 'master'

ref:staging/dune-typetree\> This removed the explicit implementation of
TreePath<i...> and makes it an alias for HybridTreePath<index_constant<i>...>.
While it is intended that TreePath is completely removed, there might be
incompatibility issues if downstream modules switch to HybridTreePath but
their users still use TreePath. Such issues should be avoided by this patch.

See merge request [!71]

  [!71]: gitlab.dune-project.org/staging/dune-typetree/merge_requests/71
parents 3fe17e1b 6aa09b51
Pipeline #27123 passed with stage
in 1 minute and 19 seconds
......@@ -30,113 +30,30 @@ namespace Dune {
enum Type { fullyStatic, dynamic };
}
template<std::size_t... i>
struct TreePath {
constexpr TreePath() = default;
constexpr TreePath(const TreePath&) = default;
constexpr TreePath(TreePath&&) = default;
typedef TreePath ViewType;
TreePath view() { return *this; }
TreePath mutablePath() { return *this; }
};
template<typename>
struct TreePathSize;
template<std::size_t... i>
struct TreePathSize<TreePath<i...> >
: public index_constant<sizeof...(i)>
{};
//! Returns the size (number of components) of the given `TreePath`.
template<std::size_t... i>
constexpr std::size_t treePathSize(const TreePath<i...>&)
{
return sizeof...(i);
}
template<typename,std::size_t>
struct TreePathPushBack;
template<std::size_t k, std::size_t... i>
struct TreePathPushBack<TreePath<i...>,k>
{
typedef TreePath<i...,k> type;
};
template<typename,std::size_t>
struct TreePathPushFront;
template<std::size_t k, std::size_t... i>
struct TreePathPushFront<TreePath<i...>,k>
{
typedef TreePath<k,i...> type;
};
template<typename>
struct TreePathBack;
// There is only a single element, so return that...
template<std::size_t k>
struct TreePathBack<TreePath<k> >
: public index_constant<k>
{};
// We need to explicitly provide two elements here, as
// the template argument pack would match the empty list
// and create a conflict with the single-element specialization.
// Here, we just shave off the first element and recursively
// instantiate ourselves.
template<std::size_t j, std::size_t k, std::size_t... l>
struct TreePathBack<TreePath<j,k,l...> >
: public TreePathBack<TreePath<k,l...> >
{};
template<typename>
struct TreePathFront;
template<std::size_t k, std::size_t... i>
struct TreePathFront<TreePath<k,i...> >
: public index_constant<k>
{};
template<typename, std::size_t...>
struct TreePathPopBack;
template<std::size_t k, std::size_t... i>
struct TreePathPopBack<TreePath<k>,i...>
{
typedef TreePath<i...> type;
};
template<std::size_t j,
std::size_t k,
std::size_t... l,
std::size_t... i>
struct TreePathPopBack<TreePath<j,k,l...>,i...>
: public TreePathPopBack<TreePath<k,l...>,i...,j>
{};
template<typename>
struct TreePathPopFront;
template<std::size_t k, std::size_t... i>
struct TreePathPopFront<TreePath<k,i...> >
{
typedef TreePath<i...> type;
};
template<typename, typename>
struct TreePathConcat;
template<std::size_t... i, std::size_t... k>
struct TreePathConcat<TreePath<i...>,TreePath<k...> >
{
typedef TreePath<i...,k...> type;
};
template<std::size_t... i>
void print_tree_path(std::ostream& os)
{}
......@@ -148,16 +65,6 @@ namespace Dune {
print_tree_path<i...>(os);
}
template<std::size_t... i>
std::ostream& operator<<(std::ostream& os, const TreePath<i...>& tp)
{
os << "TreePath< ";
print_tree_path<i...>(os);
os << ">";
return os;
}
//! A hybrid version of TreePath that supports both compile time and run time indices.
/**
* A `HybridTreePath` supports storing a combination of run time and compile time indices.
......@@ -522,6 +429,9 @@ namespace Dune {
return os;
}
template<std::size_t... i>
using TreePath = HybridTreePath<Dune::index_constant<i>...>;
//! \} group TypeTree
} // namespace TypeTree
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment