Commit dd7dab18 authored by Steffen Müthing's avatar Steffen Müthing

[!49] Make Child<> an invalid type if the child cannot be extracted

Merge branch 'feature/make-child-template-invalid-if-child-not-found' into 'master'

ref:staging/dune-typetree The type alias Child<Node,...> used to simply be
void if the child type could not be extracted. That is rather unhelpful, as it
makes it impossible to use in SFINAE.

This patch changes the behavior by making it impossible to instantiate the
type alias if there is no valid child.

See merge request [!49]

  [!49]: gitlab.dune-project.org/staging/dune-typetree/merge_requests/49
parents 97602697 167cc792
Pipeline #15839 passed with stage
in 5 minutes and 22 seconds
......@@ -24,6 +24,9 @@ TypeTree 2.7-git
to be compatible with `DynamicTreePath`.
- A `HybridTreePath` can now be constructed using the
global `treePath()` function which is an alias for `hybridTreePath()`.
- The type alias template `Child<>` now fails to instantiate if the child cannot be extracted.
This is much more useful than the previous behavior of just defaulting to `void` in case of
failure.
TypeTree 2.6
......
......@@ -285,12 +285,21 @@ namespace Dune {
namespace impl {
template<typename Node, std::size_t... indices>
struct _Child
template<typename T>
struct filter_void
{
using type = std::decay_t<decltype(child(std::declval<Node>(),index_constant<indices>{}...))>;
using type = T;
};
template<>
struct filter_void<void>
{};
template<typename Node, std::size_t... indices>
struct _Child
: public filter_void<std::decay_t<decltype(child(std::declval<Node>(),index_constant<indices>{}...))>>
{};
}
#endif // DOXYGEN
......
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