Create a variant from valueOrAllocator.

Synopsis

Declared in <bdlb_variant.h>

template<class TYPE_OR_ALLOCATOR>
explicit
Variant(TYPE_OR_ALLOCATOR const& valueOrAllocator);

Description

If valueOrAllocator is not a bslma::Allocator *, then the variant will hold the value and type of valueOrAllocator, and use the currently installed default allocator to supply memory. Otherwise, the variant will be unset and use valueOrAllocator to supply memory. TYPE_OR_ALLOCATOR must be the same as one of the types that this variant can hold or be convertible to bslma::Allocator *. Note that this parameterized constructor is defined instead of two constructors (one taking a bslma::Allocator * and the other not) because template parameter arguments are always a better match than derived‐to‐base conversion (a concrete allocator pointer converted to `bslma::Allocator *`).

Parameters

Name

Description

valueOrAllocator

held value, or allocator if convertible to bslma::Allocator *

Created with MrDocs