BloombergLP::bdlb::VariantImp::apply

Apply visitor to the held TYPE value of this variant.

Synopsis

Declared in <bdlb_variant.h>

template<
    class RET_TYPE,
    class VISITOR,
    class TYPE>
RET_TYPE
apply(
    VISITOR& visitor,
    TYPE const& defaultValue) const;

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.

Return Value

result of invoking visitor on the active alternative

Parameters

NameDescription
visitorcallable applied to the active alternative
defaultValuevalue passed to visitor when this variant is unset