Commit 167cc792 authored by Steffen Müthing's avatar Steffen Müthing

Make Child<> an invalid type if the child cannot be extracted

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.
parent 97602697
Pipeline #15838 passed with stage
in 3 minutes and 41 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
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;
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