Return the result of invoking visitor with the active alternative of variant, converted to t_RET.
Synopsis
Declared in <bslstl_variant.h>
template<
class t_RET,
class t_VISITOR,
class t_VARIANT>
t_RET
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, 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.
Return Value
result of invoking visitor, converted to t_RET
Parameters
Name |
Description |
visitor |
callable to invoke on the active alternative |
variant |
variant whose active alternative is visited |
Created with MrDocs