mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 05:25:54 +08:00
Add type checking to find_child()
Ensure that find_child() with impossible child nodes will now error at compile time.
This commit is contained in:
parent
020fe5ccdf
commit
3b64a256b6
@ -161,6 +161,7 @@ class tnode_t {
|
||||
/// Find the first direct child of the given node of the given type. asserts on failure.
|
||||
template <class ChildType>
|
||||
tnode_t<ChildType> find_child() const {
|
||||
static_assert(child_type_possible<Type, ChildType>(), "Cannot have that type as a child");
|
||||
assert(nodeptr && "receiver is missing in find_child()");
|
||||
tnode_t<ChildType> result{tree, &tree->find_child(*nodeptr, ChildType::token)};
|
||||
assert(result && "cannot find child");
|
||||
|
Loading…
x
Reference in New Issue
Block a user