[#bsl-visit-0de] = xref:bsl.adoc[bsl]::visit :relfileprefix: ../ :mrdocs: `visit` overloads == Synopses Declared in `<bslstl_variant.h>` 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. [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 xref:bsl/visit-0d1.adoc[visit]( t_VISITOR&& visitor, t_VARIANT&& variant); ---- [.small]#xref:bsl/visit-0d1.adoc[_» more..._]# Return the result of invoking the specified `visitor` with the currently active alternative of the specified `variant`, implicitly converting the result to the explicitly specified (template parameter) `t_RET`. If `variant` does not hold a value, throw an exception of type `bsl::bad_variant_access`. Note that unlike the `visit` overload below that deduces its return type, this overload does not require the visitor to yield the exact same type for each alternative, but only requires each such type to be implicitly convertible to `t_RET`. 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_RET, class t_VISITOR, class t_VARIANT> t_RET xref:bsl/visit-0f.adoc[visit]( t_VISITOR&& visitor, t_VARIANT&& variant); ---- [.small]#xref:bsl/visit-0f.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#