Value‐semantic wrapper that adds a null state to TYPE.

Synopsis

Declared in <bdlb_nullablevalue.h>

template<class TYPE>
class NullableValue
    : public bsl::optional<TYPE>

Description

This template class extends the set of values of its value‐semantic TYPE parameter to include the notion of a "null" value. If TYPE is fully value‐semantic, then the augmented type NullableValue<TYPE> will be as well. In addition to supporting all homogeneous value‐semantic operations, conversions between comparable underlying value types is also supported. Two nullable objects with different underlying types compare equal if their underlying types are comparable and either (1) both objects are null or (2) the non‐null values compare equal. A null nullable object is considered ordered before any non‐null nullable object. Attempts to copy construct, copy assign, or compare incompatible values types will fail to compile. The NullableValue template cannot be instantiated on an incomplete type, a type that overloads unary operator&, or bsl::nullopt_t.

Base Classes

Name

Description

bsl::optional<TYPE>

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

Type Aliases

Name

Description

Base

Base class of this type.

ValueType

ValueType is an alias for the underlying TYPE upon which this template class is instantiated, and represents the type of the managed object.

allocator_type

Allocator type used by this object.

value_type

Alias for the managed object type of this optional.

Member Functions

Name

Description

NullableValue [constructor]

Constructors

operator=

Assignment operators

addressOr

Return the address of the contained object, or address if null.

and_then

and_then overloads

bdexStreamIn

Assign to this object the value read from the specified stream.

bdexStreamOut

Write this object to the specified output stream.

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.

isNull

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

makeValue

makeValue overloads

makeValueInplace

Construct a TYPE object in place from the specified args.

maxSupportedBdexVersion

maxSupportedBdexVersion overloads

operator*

Dereference operators

operator‐>

Member access operators

or_else

Return this optional if engaged; otherwise invoke func.

print

Format this object to the specified output stream.

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

valueOr

valueOr overloads

valueOrNull

Return an address providing non‐modifiable access to the underlying object of a (template parameter) TYPE if this object is non‐null, and 0 otherwise.

value_or

Return the contained value, or a converted fallback if disengaged.

operator BloombergLP::bslmf::NestedTraitDeclaration<NullableValue, HasPrintMethod>

NullableValue always provides a print method.

operator BloombergLP::bslmf::NestedTraitDeclaration<NullableValue, IsBitwiseCopyable, bslmf::IsBitwiseCopyable<TYPE>::value>

NullableValue is bitwise copyable when TYPE is bitwise copyable.

operator BloombergLP::bslmf::NestedTraitDeclaration<NullableValue, IsBitwiseMoveable, bslmf::IsBitwiseMoveable<TYPE>::value>

NullableValue is bitwise moveable when TYPE is bitwise moveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<NullableValue, UsesBslmaAllocator, bslma::UsesBslmaAllocator<TYPE>::value>

NullableValue uses a bslma::Allocator when TYPE does.

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

Name

Description

AllocType

This typedef is an alias to allocator_type.

Protected Member Functions

Name

Description

assignOrEmplace

Assign or emplace a value into this optional.

dereferenceRaw

Return a reference to the contained value without checking engagement.

Friends

Name

Description

BloombergLP::bdlb::NullableValue

Value‐semantic wrapper that adds a null state to TYPE.

Non-Member Functions

Name

Description

nullableValue_acceptsBslOptional

Component‐private constraint helper for bsl::optional conversion.

operator!=

Return true if the specified nullable objects do not have the same value.

operator!=

Return whether the specified lhs and rhs do not have the same value.

operator!=

Return true if the specified nullable object and std::optional do not have the same value.

operator!=

Return whether the specified lhs and rhs do not have the same value.

operator!=

Return true if the specified nullable objects do not have the same value.

operator!=

Return true if the specified nullable objects do not have the same value.

operator<

Return whether the specified lhs is ordered before the specified rhs.

operator<

Return true if lhs is ordered before rhs, and false otherwise.

operator<

Return true if lhs is ordered before rhs, and false otherwise.

operator<

Return true if lhs is ordered before rhs, and false otherwise.

operator<

Return whether the specified lhs is ordered before the specified rhs.

operator<

Return whether the left‐hand operand is ordered before the right.

operator<=

Return whether the specified lhs is ordered before or equal to rhs.

operator<=

Return whether the left‐hand operand is before or equal to the right.

operator<=

Return true if lhs is ordered before rhs or they are equal.

operator<=

Return true if lhs is ordered before rhs or they are equal.

operator<=

Return true if lhs is ordered before rhs or they are equal.

operator<=

Return whether the specified lhs is ordered before or equal to rhs.

operator<=>

Return a three‐way comparison of the specified lhs and rhs.

operator<=>

Perform a three‐way comparison of the specified nullable objects.

operator<=>

Perform a three‐way comparison of the specified value and one of type bsl::nullopt_t; return the result of that comparison.

operator<=>

Perform a three‐way comparison of the specified nullable objects.

operator<=>

Perform a three‐way comparison of the specified nullable object and value.

operator==

Return true if the specified value is null, and false otherwise.

operator==

Return true if the specified nullable objects have the same value.

operator==

Return true if the specified nullable objects have the same value, and false otherwise.

operator==

Return true if the specified nullable objects have the same value.

operator==

Return whether the specified lhs and rhs have the same value.

operator==

Return whether the specified lhs and rhs have the same value.

operator==

Return true if the specified nullable objects have the same value, and false otherwise.

operator>

Return true if lhs is ordered after rhs, and false otherwise.

operator>

Return true if lhs is ordered after rhs, and false otherwise.

operator>

Return true if lhs is ordered after rhs, and false otherwise.

operator>

Return whether the left‐hand operand is ordered after the right.

operator>

Return whether the specified lhs is ordered after the specified rhs.

operator>

Return whether the specified lhs is ordered after the specified rhs.

operator>=

Return whether the left‐hand operand is after or equal to the right.

operator>=

Return whether the specified lhs is ordered after or equal to rhs.

operator>=

Return whether the specified lhs is ordered after or equal to rhs.

operator>=

Return true if lhs is ordered after rhs or they are equal.

operator>=

Return true if lhs is ordered after rhs or they are equal.

operator>=

Return true if lhs is ordered after rhs or they are equal.

swap

Exchange the values of the specified lhs and rhs objects when TYPE does not use a bslma::Allocator.

swap

Exchange the values of the specified lhs and rhs objects.

::bsl::PrintTo

Write the specified value to the specified *stream, surrounded by double quotes.

::bsl::operator!=

Return whether the operands do not have the same value.

::bsl::operator!=

Return whether the operands do not have the same value.

::bsl::operator!=

Return whether the operands do not have the same value.

::bsl::operator<

Return whether the left‐hand operand is ordered before the right.

::bsl::operator<

Return whether the left‐hand operand is ordered before the right.

::bsl::operator<

Return whether the left‐hand operand is ordered before the right.

::bsl::operator<=

Return whether the left‐hand operand is before or equal to the right.

::bsl::operator<=

Return whether the left‐hand operand is before or equal to the right.

::bsl::operator<=

Return whether the left‐hand operand is before or equal to the right.

::bsl::operator<=>

Perform a three‐way comparison of the operands.

::bsl::operator<=>

Perform a three‐way comparison of the operands.

::bsl::operator<=>

Perform a three‐way comparison of the operands.

::bsl::operator<=>

Perform a three‐way comparison of the operands.

::bsl::operator==

Return whether the operands have the same value.

::bsl::operator==

Return whether the operands have the same value.

::bsl::operator==

Compare a std::optional with a bsl::optional for equality.

::bsl::operator==

Return whether the operands have the same value.

::bsl::operator>

Return whether the left‐hand operand is ordered after the right.

::bsl::operator>

Return whether the left‐hand operand is ordered after the right.

::bsl::operator>

Return whether the left‐hand operand is ordered after the right.

::bsl::operator>=

Return whether the left‐hand operand is after or equal to the right.

::bsl::operator>=

Return whether the left‐hand operand is after or equal to the right.

::bsl::operator>=

Return whether the left‐hand operand is after or equal to the right.

::bsl::swap

Exchange the values of two optionals.

::bsl::swap

Exchange the values of two optionals.

::bsl::swap

Exchange the values of two optionals.

::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueAccessValue

Default customization‐point implementation of accessValue for bdlb::NullableValue.

::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueIsNull

Return whether the specified nullable object is null.

::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueMakeValue

Default customization‐point implementation of makeValue for bdlb::NullableValue.

::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueManipulateValue

Default customization‐point implementation of manipulateValue for bdlb::NullableValue.

::BloombergLP::bslstl::optional_acceptsBslOptional

Component‐private constraint helper for Optional_DerivedFromBslOptional.

Created with MrDocs