bsl::optional

Allocator-aware nullable wrapper for an object of type t_TYPE.

Synopsis

Declared in <bslstl_optional.h>

template<class t_TYPE>
class optional
    : public BloombergLP::bslstl::Optional_Base<t_TYPE>

Base Classes

NameDescription
BloombergLP::bslstl::Optional_Base<t_TYPE>Component-private class template implementing bsl::optional.

Type Aliases

NameDescription
allocator_type This typedef is an alias to bsl::allocator<char>.
value_type Alias for the managed object type of this optional.

Member Functions

NameDescription
optional [constructor]Constructors
operator= Assignment operators
and_then and_then overloads
emplace Destroy any contained value and construct a new one in place.
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
or_else Return this optional if engaged; otherwise invoke func.
reset Reset this object to the default constructed state (i.e., to a disengaged state).
swap Exchange the values of two optionals.
transform transform overloads
value value overloads
value_or Return the contained value, or a converted fallback if disengaged.
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 BloombergLP::bslmf::NestedTraitDeclaration<optional, IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value> Nested trait declaration for bslmf::IsBitwiseCopyable.
operator BloombergLP::bslmf::NestedTraitDeclaration<optional, IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value> Nested trait declaration for bslmf::IsBitwiseMoveable.
operator BloombergLP::bslmf::NestedTraitDeclaration<optional, UsesAllocatorArgT, BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value> Nested trait declaration for bslmf::UsesAllocatorArgT.
operator BloombergLP::bslmf::NestedTraitDeclaration<optional, UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value> Nested trait declaration for bslma::UsesBslmaAllocator.
operator bool Return false if this object is disengaged, and true otherwise.

Protected Type Aliases

NameDescription
AllocType This typedef is an alias to allocator_type.

Protected Member Functions

NameDescription
assignOrEmplace Assign or emplace a value into this optional.
dereferenceRaw Return a reference to the contained value without checking engagement.

Deduction Guides

NameDescription
optional<t_TYPE> Deduce the specified type t_TYPE from the corresponding type supplied to the constructor of optional.
optional<t_TYPE> Deduce t_TYPE for an allocator-aware optional from a value.
optional<t_TYPE> Deduce t_TYPE for an allocator-aware optional from another optional.

Friends

NameDescription
bsl::optionalAllocator-aware nullable wrapper for an object of type t_TYPE.

Non-Member Functions

NameDescription
PrintToWrite the specified value to the specified *stream, surrounded by double quotes.
make_optionalReturn an optional containing a value constructed from the arguments.
make_optionalReturn an optional object containing a value-initialized t_TYPE object.
make_optionalReturn an optional containing a value constructed from the arguments.
make_optionalReturn an optional containing a value constructed from the arguments.
make_optionalReturn an optional containing a value constructed from the arguments.
make_optionalReturn an optional containing a value constructed from the arguments.
make_optionalReturn an optional containing a value constructed from the arguments.
operator!=Return whether the operands do not have the same value.
operator!=Return whether the operands do not have the same value.
operator!=Return whether the operands do not have the same value.
operator<Return whether the left-hand operand is ordered before the right.
operator<Return whether the left-hand operand is ordered before the right.
operator<Return whether the left-hand operand is ordered before the right.
operator<=Return whether the left-hand operand is before or equal to the right.
operator<=Return whether the left-hand operand is before or equal to the right.
operator<=Return whether the left-hand operand is before or equal to the right.
operator<=>Perform a three-way comparison of the operands.
operator<=>Perform a three-way comparison of the operands.
operator<=>Perform a three-way comparison of the operands.
operator<=>Perform a three-way comparison of the operands.
operator==Return whether the operands have the same value.
operator==Return whether the operands have the same value.
operator==Compare a std::optional with a bsl::optional for equality.
operator==Return whether the operands have the same value.
operator>Return whether the left-hand operand is ordered after the right.
operator>Return whether the left-hand operand is ordered after the right.
operator>Return whether the left-hand operand is ordered after the right.
operator>=Return whether the left-hand operand is after or equal to the right.
operator>=Return whether the left-hand operand is after or equal to the right.
operator>=Return whether the left-hand operand is after or equal to the right.
swapExchange the values of two optionals.
swapExchange the values of two optionals.
swapExchange the values of two optionals.
::BloombergLP::bdlb::nullableValue_acceptsBslOptionalComponent-private constraint helper for bsl::optional conversion.
::BloombergLP::bdlb::operator!=Return true if the specified nullable objects do not have the same value.
::BloombergLP::bdlb::operator!=Return true if the specified nullable objects do not have the same value.
::BloombergLP::bdlb::operator<Return true if lhs is ordered before rhs, and false otherwise.
::BloombergLP::bdlb::operator<Return whether the left-hand operand is ordered before the right.
::BloombergLP::bdlb::operator<=Return whether the left-hand operand is before or equal to the right.
::BloombergLP::bdlb::operator<=Return true if lhs is ordered before rhs or they are equal.
::BloombergLP::bdlb::operator==Return true if the specified nullable objects have the same value.
::BloombergLP::bdlb::operator==Return true if the specified nullable objects have the same value, and false otherwise.
::BloombergLP::bdlb::operator>Return true if lhs is ordered after rhs, and false otherwise.
::BloombergLP::bdlb::operator>Return whether the left-hand operand is ordered after the right.
::BloombergLP::bdlb::operator>=Return whether the left-hand operand is after or equal to the right.
::BloombergLP::bdlb::operator>=Return true if lhs is ordered after rhs or they are equal.
::BloombergLP::bslstl::optional_acceptsBslOptionalComponent-private constraint helper for Optional_DerivedFromBslOptional.

Derived Classes

NameDescription
NullableValue Value-semantic wrapper that adds a null state to TYPE.