Template Function tvm::ffi::StructuralVisitExpected

Template Function tvm::ffi::StructuralVisitExpected#

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 returns Expected<Optional<VisitInterrupt>>. The first argument follows the same matching rules as StructuralWalk; 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::nullopt completes that subtree, a VisitInterrupt halts the traversal, and an Error fails 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::nullopt if traversal completed, or the interrupt that halted it.