This component‐private class template implements the functionality of bsl::optional. The primary template is instantiated when TYPE is allocator‐aware, and holds the allocator that is used to create the stored object.

Synopsis

Declared in <bslstl_optional.h>

template<
    class t_TYPE,
    bool t_USES_BSLMA_ALLOC = BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>
class Optional_Base;

Type Aliases

Name

Description

allocator_type

This typedef is an alias to bsl::allocator<char>.

value_type

value_type is an alias for the underlying TYPE upon which this template class is instantiated, and represents the type of the managed object. The name is chosen so it is compatible with the std::optional implementation.

Member Functions

Name

Description

operator=

Assignment operators

emplace

emplace overloads

get_allocator

Return allocator used for construction of value_type.

has_value

Return false if this object is disengaged, and true otherwise.

operator*

Dereference operators

operator‐>

Member access operators

reset

Reset this object to the default constructed state (i.e., to a disengaged state).

swap

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no‐throw exception‐safety guarantee if the template parameter t_TYPE provides that guarantee and the result of the hasValue method for the two objects being swapped is the same. The behavior is undefined unless this object was created with the same allocator as other.

value

value overloads

value_or

value_or overloads

operator BloombergLP::bslmf::NestedTraitDeclaration<Optional_Base, IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value>

Nested trait declaration for bslmf::IsBitwiseCopyable.

operator BloombergLP::bslmf::NestedTraitDeclaration<Optional_Base, IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value>

Nested trait declaration for bslmf::IsBitwiseMoveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<Optional_Base, UsesAllocatorArgT>

Nested trait declaration for bslmf::UsesAllocatorArgT.

operator BloombergLP::bslmf::NestedTraitDeclaration<Optional_Base, UsesBslmaAllocator>

Nested trait declaration for bslma::UsesBslmaAllocator.

operator bool

Return false if this object is disengaged, and true otherwise.

Protected Type Aliases

Name

Description

AllocType

This typedef is an alias to allocator_type.

Protected Member Functions

Name

Description

Optional_Base [constructor]

Constructors

assignOrEmplace

If *this holds an object, assign to that object the value of the specified rhs, converted to t_TYPE. Otherwise, construct a held object from rhs, converted to t_TYPE. The allocators of *this and rhs remain unchanged.

dereferenceRaw

dereferenceRaw overloads

Specializations

Name

Description

Optional_Base<t_TYPE, false>

Specialization of Optional_Base for value_type that is not allocator‐aware when std::optional is available.

Derived Classes

Name

Description

optional

Created with MrDocs