14 E operator*()
const {
return node; }
15 typename std::remove_reference<E>::type* operator->()
const {
return &node; }
19 Location(E node =
nullptr,
int child = 0) : node(node), child(child) {}
28 using Erased =
typename std::decay<E>::type;
37 const std::vector<Location<E>>&
path;
52 E
parent(
unsigned int parent_nr = 1)
const {
53 if ( path.size() < 1 + parent_nr )
54 throw std::out_of_range(
"node does not have requested parent");
56 return (**(path.end() - 1 - parent_nr));
61 std::optional<std::reference_wrapper<const T>>
findParent()
const {
62 for (
auto i = path.rbegin() + 1; i != path.rend(); i++ ) {
63 if ( (**i).template isA<T>() )
64 return {(**i).template as<T>()};
Definition: operator.h:22
auto pathLength() const
Definition: visitor-types.h:44
Definition: visitor-types.h:26
E node
Definition: visitor-types.h:31
const std::vector< Location< E > > & path
Definition: visitor-types.h:37
std::optional< std::reference_wrapper< const T > > findParent() const
Definition: visitor-types.h:61
Definition: visitor-types.h:12
E parent(unsigned int parent_nr=1) const
Definition: visitor-types.h:52