[#bsl-visit-0d1] = xref:bsl.adoc[bsl]::visit :relfileprefix: ../ :mrdocs: Return the result of invoking `visitor` with the active alternative of `variant`. == Synopsis Declared in `<bslstl_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | *visitor* | callable to invoke on the active alternative | *variant* | variant whose active alternative is visited |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#