Template Function tvm::ffi::StructuralVisitExpected#
Defined in File structural_visit.h
Function Documentation#
-
template<typename ...Callbacks>
Expected<Optional<VisitInterrupt>> tvm::ffi::StructuralVisitExpected(AnyView root, Callbacks&&... callbacks) noexcept# Visit a structured value, letting a matched callback own descent.
Each callback takes
(value, StructuralVisitorObj* visitor)and returnsExpected<Optional<VisitInterrupt>>. The first argument follows the same matching rules asStructuralWalk; callbacks are tested in declaration order and the first match is used.A matched callback owns descent into its value, and its result is final. Returning
std::nulloptcompletes that subtree, aVisitInterrupthalts the traversal, and anErrorfails it. A value matching no callback uses the visitor’s default descent.- Template Parameters:
Callbacks – Callback types.
- Parameters:
root – The root value to visit.
callbacks – Callbacks invoked for matching nodes.
- Returns:
std::nulloptif traversal completed, or the interrupt that halted it.