[#BloombergLP-bdlb-Variant2-apply]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/Variant2.adoc[Variant2]::apply
:relfileprefix: ../../../
:mrdocs:

`apply` overloads

== Synopses

Declared in `&lt;bdlb&lowbar;variant&period;h&gt;`

Apply the specified `visitor` to this modifiable variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class VISITOR&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-0ec.adoc[apply](VISITOR& visitor)
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0ec.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class VISITOR&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-073.adoc[apply](VISITOR& visitor) const
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-073.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this modifiable variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class VISITOR&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-034.adoc[apply](VISITOR const& visitor)
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-034.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the &apos;visitor&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class VISITOR&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-00.adoc[apply](VISITOR const& visitor) const
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-00.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-02f.adoc[apply](VISITOR& visitor);
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-02f.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-0f6.adoc[apply](VISITOR& visitor) const;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0f6.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload, but for a `const` visitor&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-062.adoc[apply](VISITOR const& visitor);
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-062.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-0a.adoc[apply](VISITOR const& visitor) const;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0a.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VISITOR,
    class TYPE&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-08.adoc[apply](
    VISITOR& visitor,
    TYPE const& defaultValue)
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-08.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VISITOR,
    class TYPE&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-0e2.adoc[apply](
    VISITOR& visitor,
    TYPE const& defaultValue) const
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0e2.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VISITOR,
    class TYPE&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-021.adoc[apply](
    VISITOR const& visitor,
    TYPE const& defaultValue)
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-021.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VISITOR,
    class TYPE&gt;
VISITOR::ResultType
xref:BloombergLP/bdlb/VariantImp/apply-075f.adoc[apply](
    VISITOR const& visitor,
    TYPE const& defaultValue) const
requires Variant&lowbar;ReturnValueHelper&lt;VISITOR&gt;&colon;&colon;value &equals;&equals; 1;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-075f.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR,
    class TYPE&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-028.adoc[apply](
    VISITOR& visitor,
    TYPE const& defaultValue);
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-028.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR,
    class TYPE&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-0e3.adoc[apply](
    VISITOR& visitor,
    TYPE const& defaultValue) const;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0e3.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload, but for a `const` visitor&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR,
    class TYPE&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-0fc.adoc[apply](
    VISITOR const& visitor,
    TYPE const& defaultValue);
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-0fc.adoc[_» more&period;&period;&period;_]#

Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class RET&lowbar;TYPE,
    class VISITOR,
    class TYPE&gt;
RET&lowbar;TYPE
xref:BloombergLP/bdlb/VariantImp/apply-03c.adoc[apply](
    VISITOR const& visitor,
    TYPE const& defaultValue) const;
----

[.small]#xref:BloombergLP/bdlb/VariantImp/apply-03c.adoc[_» more&period;&period;&period;_]#


[.small]#Created with https://www.mrdocs.com[MrDocs]#
