[#BloombergLP-bdlb-NullableValueRef] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::NullableValueRef :relfileprefix: ../../ :mrdocs: This class is a wrapper for either a `bsl::optional` or `NullableAllocatedValue`, and provides modifiable access to the wrapped object. == Synopsis Declared in `<bdlb_nullablevalueref.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class NullableValueRef; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/NullableValueRef/value_type.adoc[`value_type`] | `value_type` is an alias for the template parameter `TYPE`, and represents the type of the object managed by the wrapped nullable object. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/NullableValueRef/2constructor-0d8.adoc[`NullableValueRef`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlb/NullableValueRef/operator_assign-08.adoc[`operator=`] | Assignment operators | xref:BloombergLP/bdlb/NullableValueRef/addressOr.adoc[`addressOr`] | Return an address providing non‐modifiable access to the underlying object of a (template parameter) `TYPE` if this object is non‐null, and the specified `address` otherwise. | xref:BloombergLP/bdlb/NullableValueRef/emplace.adoc[`emplace`] | Assign to the target the value of the (template parameter) `TYPE` created in place using the specified `args` and return a reference providing modifiable access to the underlying `TYPE` object. If this `optional` object already contains an object (`true == hasValue()`), that object is destroyed before the new object is created. Note that if the constructor of `TYPE` throws an exception this object is left in a disengaged state. | xref:BloombergLP/bdlb/NullableValueRef/has_value.adoc[`has_value`] | Return `true` if the target contains a value, and `false` otherwise. | xref:BloombergLP/bdlb/NullableValueRef/isNull.adoc[`isNull`] | Return `false` if the target contains a value, and `true` otherwise. Note that this accessor is provided purely for compatibility with `NullableValue` and `NullableAllocatedValue`, and its use is discouraged in favor of `has_value`. | xref:BloombergLP/bdlb/NullableValueRef/makeValueInplace.adoc[`makeValueInplace`] | Assign to this nullable object the value of the (template parameter) `TYPE` created in place using the specified `args`. Return a reference providing modifiable access to the created (value) object. The object is also accessible via the `value` method. If this nullable object already contains an object (`false == isNull()`), that object is destroyed before the new object is created. If `TYPE` has the trait `bslma::UsesBslmaAllocator` (`TYPE` is allocator‐enabled) the allocator specified at the construction of this nullable object is used to supply memory to the value object. Attempts to explicitly specify via `args` another allocator to supply memory to the created (value) object are disallowed by the compiler. Note that if the constructor of `TYPE` throws an exception this object is left in the null state. | xref:BloombergLP/bdlb/NullableValueRef/operator_star-08e.adoc[`operator*`] | Dereference operators | xref:BloombergLP/bdlb/NullableValueRef/operator_ptr-0a.adoc[`operator‐>`] | Member access operators | xref:BloombergLP/bdlb/NullableValueRef/reset.adoc[`reset`] | Reset the target to the default constructed state (i.e., to have the null value). | xref:BloombergLP/bdlb/NullableValueRef/value-04.adoc[`value`] | `value` overloads | xref:BloombergLP/bdlb/NullableValueRef/valueOr.adoc[`valueOr`] | Return the value of the underlying object of a (template parameter) `TYPE` if this object is non‐null, and the specified `otherValue` otherwise. Note that this method returns _by_ _value_, so may be inefficient in some contexts. | xref:BloombergLP/bdlb/NullableValueRef/valueOrNull.adoc[`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. | xref:BloombergLP/bdlb/NullableValueRef/value_or.adoc[`value_or`] | Return the value of the underlying object of a (template parameter) `TYPE` if the target is non‐null, and the specified `default_value` otherwise. Note that this method returns _by_ _value_, so may be inefficient in some contexts. | xref:BloombergLP/bdlb/NullableValueRef/2conversion.adoc[`operator bool`] | Return `true` if the target holds a value, and `false` otherwise. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlb/ConstNullableValueRef.adoc[BloombergLP::bdlb::ConstNullableValueRef]` | This class is a wrapper for either a `bsl::optional` or `NullableAllocatedValue`, and provides non‐modifiable access to the wrapped object. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/operator_not_eq-00d.adoc[`operator!=`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_not_eq-00fa.adoc[`operator!=`] | Return `true` if the specified `lhs` and `rhs` objects do not have the same value, and `false` otherwise. A nullable wrappers and a value of some type do not have the same value if either the nullable wrappers is null, or its underlying value does not compare equal to the other value. Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_not_eq-076.adoc[`operator!=`] | Return `true` if the specified `lhs` is not null, and `false` otherwise. | xref:BloombergLP/bdlb/operator_not_eq-0d.adoc[`operator!=`] | Return `true` if the specified `lhs` and `rhs` nullable objects do not have the same value, and `false` otherwise. Two nullable wrappers do not have the same value if one is null and the other is non‐null, or if both are non‐null and the values of their underlying objects do not compare equal. Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_lt-020.adoc[`operator<`] | Return `false`. `bsl::nullopt` never orders after a `NullableValueRef`. | xref:BloombergLP/bdlb/operator_lt-02f.adoc[`operator<`] | Return `true` if the specified `lhs` nullable wrapper is ordered before the specified `rhs`, and `false` otherwise. `lhs` is ordered before `rhs` if `lhs` is null or `lhs.value()` is ordered before `rhs`. | xref:BloombergLP/bdlb/operator_lt-037.adoc[`operator<`] | Return `true` if the specified `lhs` nullable wrapper is ordered before the specified `rhs` nullable object, and `false` otherwise. `lhs` is ordered before `rhs` if `lhs` is null and `rhs` is non‐null or if both are non‐null and `lhs.value()` is ordered before `rhs.value()`. Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_lt-0f0.adoc[`operator<`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_le-03f.adoc[`operator<=`] | Return `true` if the specified `lhs` nullable wrapper is ordered before the specified `rhs` or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator<` and `operator==`.) Note that this operator returns `!(rhs < lhs)`. | xref:BloombergLP/bdlb/operator_le-07.adoc[`operator<=`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_le-0fd.adoc[`operator<=`] | Return `true` if the specified `lhs` nullable wrapper is ordered before the specified `rhs` nullable object or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator<` and `operator==`.) Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_le-0ff.adoc[`operator<=`] | Return `true` if the specified `lhs` is null, and `false` otherwise. | xref:BloombergLP/bdlb/operator_eq-013ae.adoc[`operator==`] | Return `true` if the specified `lhs` is null, and `false` otherwise. | xref:BloombergLP/bdlb/operator_eq-06d.adoc[`operator==`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_eq-07f.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` nullable wrappers have the same value, and `false` otherwise. Two nullable wrappers have the same value if both targets are null, or if both are non‐null and the values of their underlying objects compare equal. Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_eq-0a9.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise. A nullable wrapper and a value of some type have the same value if the nullable wrapper is non‐null and the underlying value of it's target compares equal to the other value. Note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_gt-0110.adoc[`operator>`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_gt-0c5e.adoc[`operator>`] | Return `true` if the specified `lhs` nullable wrapper is ordered after the specified `rhs` nullable object, and `false` otherwise. `lhs` is ordered after `rhs` if `lhs` is non‐null and `rhs` is null or if both are non‐null and `lhs.value()` is ordered after `rhs.value()`. Note that this operator returns `rhs < lhs` when both operands are of `bsl::optional` type. Also note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_gt-0e.adoc[`operator>`] | Return `true` if the specified `lhs` nullable wrapper is ordered after the specified `rhs`, and `false` otherwise. `lhs` is ordered after `rhs` if `lhs` is not null and `lhs.value()` is ordered after `rhs`. Note that this operator returns `rhs < lhs`. | xref:BloombergLP/bdlb/operator_gt-0f5.adoc[`operator>`] | Return `true` if the specified `lhs` is not null, and `false` otherwise. | xref:BloombergLP/bdlb/operator_ge-037.adoc[`operator>=`] | Return `true` if the specified `lhs` nullable wrapper is ordered after the specified `rhs` or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator>` and `operator==`.) Note that this operator returns `!(lhs < rhs)`. | xref:BloombergLP/bdlb/operator_ge-03d.adoc[`operator>=`] | See the overload above for contract. | xref:BloombergLP/bdlb/operator_ge-05d.adoc[`operator>=`] | Return `true` if the specified `lhs` nullable object is ordered after the specified `rhs` nullable wrapper or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator>` and `operator==`.) Note that this operator returns `!(lhs < rhs)` when both operands are of `bsl::optional` type. Also note that this function will fail to compile if `LHS_TYPE` and `RHS_TYPE` are not compatible. | xref:BloombergLP/bdlb/operator_ge-0e.adoc[`operator>=`] | Return `true`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#