mrdocs::visit

Visit a polymorphic object by matching its kind to a derived type.

Synopsis

Declared in <mrdocs/Support/TypeTraits/Visitor.hpp>

template<
    class Info,
    class Fn,
    class... Args>
requires (describe::has_describe_kinds<std::remove_cvref_t<Info>>::value
        || requires { std::remove_cvref_t<Info>::kind_id; })
decltype(auto)
visit(
    Info& info,
    Fn&& fn,
    Args&&... args);

Description

Accepts either a polymorphic base registered with MRDOCS_DESCRIBE_KINDS, or one of its concrete kinds (a type carrying a kind_id).

Given a base, it reads the concrete kinds from describe::describe_kinds and calls fn with the object downcast to the kind whose kind_id equals info.Kind, followed by args.

Given a concrete kind, the type is already known statically, so there is nothing to dispatch: fn is called with info directly. This lets a caller that already holds a concrete node (e.g. the global NamespaceSymbol) pass it without casting to the base first.

Return Value

The result of calling fn with the concrete object.

Parameters

NameDescription
infoThe object to visit; when it is a base, info.Kind selects the derived type.
fnThe function called with the concrete object and args.
argsExtra arguments forwarded to fn.