Apply hybrid visitor to TypeTree.
This function applies the given hybrid visitor to the tree in a depth-first traversal and returns the accumulated value. This method is able to accumulate/transform different types on both dynamic and static trees as long as they match on consecutive calls of the visitor. On calls between dynamic childen, the carried type should be consistent. On static children types may differ as long as they are expected on the next visited node.
- Note
- Tree may be const or non-const
-
If the carried type is always the same, consider applyToTree which is less demanding on the compiler.
-
The visitor must implement the interface laid out by DefaultHybridVisitor (most easily achieved by inheriting from it) and specify the required type of tree traversal preference (static or dynamic) by inheriting from either StaticTraversal or DynamicTraversal.
- Parameters
-
tree | The tree the visitor will be applied to. |
visitor | The hybrid visitor to apply to the tree. |
init | Initial value to pass to the visitor |
- Returns
- auto Result of the last call on the visitor