bsl::visit

Return the result of invoking visitor with the active alternative of variant.

Synopsis

Declared in <bslstl_variant.h>

template<
    class t_VISITOR,
    class t_VARIANT>
bsl::invoke_result<t_VISITOR&&, decltype(get<0>(BloombergLP::bslstl::Variant_ImpUtil::
                    asVariant(std::forward<t_VARIANT>(variant))))>::type
visit(
    t_VISITOR&& visitor,
    t_VARIANT&& variant);

Description

Return the result of invoking the specified visitor with the currently active alternative of the specified variant. If variant does not hold a value, throw an exception of type bsl::bad_variant_access. For each alternative, invocation of the visitor with that alternative shall be of the same type and value category. This function differs from the standard in the following ways: * only one variant is supported * constexpr is not implemented * before C++17, only t_VISITOR(ALTERNATIVE) form of visitation is supported; cases where the visitor is a pointer to member are not supported.

Return Value

result of invoking visitor on the active alternative

Parameters

NameDescription
visitorcallable to invoke on the active alternative
variantvariant whose active alternative is visited