[#BloombergLP-bdlb-VariantImp-apply-075f] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp]::apply :relfileprefix: ../../../ :mrdocs: Apply `visitor` to the held `TYPE` value of this variant. == Synopsis Declared in `<bdlb_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class VISITOR, class TYPE> VISITOR::ResultType apply( VISITOR const& visitor, TYPE const& defaultValue) const requires Variant_ReturnValueHelper<VISITOR>::value == 1; ---- == Description If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`. `TYPE` must be the same as one of the types that this variant can hold. The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`. Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface. Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions. == Return Value result of invoking `visitor` on the active alternative == Parameters [cols="1,4"] |=== | Name| Description | *visitor* | callable applied to the active alternative | *defaultValue* | value passed to `visitor` when this variant is unset |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#