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 NullableAllocatedValue<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. Attempts to copy construct, copy assign, or compare incompatible values types will fail to compile. The NullableAllocatedValue template can be instantiated on an incomplete type, but it cannot be instantiated on a type that overloads operator&.
Declared in <bdlb_nullableallocatedvalue.h>
template<class TYPE>
class NullableAllocatedValue;
| Name | Description |
|---|---|
ValueType | ValueType is an alias for the underlying TYPE upon which this template class is instantiated, and represents the type of the managed object. |
| Name | Description |
|---|---|
NullableAllocatedValue [constructor] | Constructors |
~NullableAllocatedValue [destructor] | Destroy this object. |
operator= | Assignment operators |
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. |
allocator | Return the allocator used by this object to supply memory. |
bdexStreamIn | Assign to this object the value read from the specified input stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, this object is unaltered and stream is invalidated, but otherwise unmodified. If version is supported but stream becomes invalid during this operation, this object has an undefined, but valid, state. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers. |
bdexStreamOut | Write the value of this object, using the specified version format, to the specified output stream, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, stream is invalidated, but otherwise unmodified. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers. |
emplace | emplace overloads |
get_allocator | Return a bsl::allocator constructed from the bslma::Allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used. |
has_value | Return true if this object contains a value, and false otherwise. |
isNull | Return false if this object contains a value, and true otherwise. Note that this is the opposite of has_value. |
makeValue | makeValue overloads |
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. |
maxSupportedBdexVersion | maxSupportedBdexVersion overloads |
operator* | Dereference operators |
operator-> | Member access operators |
print | Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. |
reset | Reset this object to the default constructed state (i.e., to have the null value). |
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. The behavior is undefined unless this object was created with the same allocator as other. |
value | value overloads |
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. |
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 value of the underlying object of a (template parameter) TYPE if this object is non-null, and the specified default_value otherwise. Note that this method returns by value, so may be inefficient in some contexts. |
operator BloombergLP::bslmf::NestedTraitDeclaration<NullableAllocatedValue, HasPrintMethod> | Declare that NullableAllocatedValue provides a print method. |
operator BloombergLP::bslmf::NestedTraitDeclaration<NullableAllocatedValue, IsBitwiseMoveable> | Declare NullableAllocatedValue as bitwise moveable when TYPE is. |
operator BloombergLP::bslmf::NestedTraitDeclaration<NullableAllocatedValue, UsesBslmaAllocator> | Declare that NullableAllocatedValue uses a bslma allocator. |
operator bool | Return true if this object is contains a value, and true otherwise. |
| Name | Description |
|---|---|
operator!= | Return true if the specified lhs and rhs objects do not have the same value, and false otherwise. A nullable object and a value of some type do not have the same value if either the nullable object 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. |
operator!= | Return true if the specified lhs and rhs nullable objects do not have the same value, and false otherwise. Two nullable objects 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. |
operator!= | Return true if the specified lhs is not null, and false otherwise. |
operator!= | If neither of the specified lhs and rhs contain a value, return false. If one contains a value, and the other does not, return true. Otherwise, return lhs.value != rhs.value(). |
operator< | Return false. Note that bsl::nullopt never orders after a NullableAllocatedValue. |
operator< | If neither of the specified lhs and rhs contain a value, return false. If lhs contains a value, and rhs does not, return false. If lhs does not contains a value, rhs does, return true. Otherwise, return lhs.value < rhs.value(). |
operator< | Return true if the specified lhs nullable object 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. |
operator< | Return true if the specified lhs nullable object 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. |
operator<= | Return true if the specified lhs is null, and false otherwise. |
operator<= | Return true if the specified lhs nullable object 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 operator returns !(rhs < lhs) when both operands are of NullableValue type. Also note that this function will fail to compile if LHS_TYPE and RHS_TYPE are not compatible. |
operator<= | If neither of the specified lhs and rhs contain a value, return true. If lhs contains a value, and rhs does not, return false. If lhs does not contains a value, rhs does, return true. Otherwise, return lhs.value <= rhs.value(). |
operator<= | Return true if the specified lhs nullable object 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). |
operator== | If neither of the specified lhs and rhs contain a value, return true. If one contains a value, and the other does not, return false. Otherwise, return lhs.value == rhs.value(). |
operator== | Return true if the specified lhs is null, and false otherwise. |
operator== | Return true if the specified lhs and rhs objects have the same value, and false otherwise. A nullable object and a value of some type have the same value if the nullable object is non-null and its underlying value compares equal to the other value. Note that this function will fail to compile if LHS_TYPE and RHS_TYPE are not compatible. |
operator== | Return true if the specified lhs and rhs nullable objects have the same value, and false otherwise. Two nullable objects have the same value if both 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. |
operator> | Return true if the specified lhs nullable object 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. |
operator> | Return true if the specified lhs nullable object 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 NullableValue type. Also note that this function will fail to compile if LHS_TYPE and RHS_TYPE are not compatible. |
operator> | If neither of the specified lhs and rhs contain a value, return false. If lhs contains a value, and rhs does not, return true. If lhs does not contains a value, rhs does, return false. Otherwise, return lhs.value > rhs.value(). |
operator> | Return true if the specified lhs is not null, and false otherwise. |
operator>= | Return true. |
operator>= | Return true if the specified lhs nullable object is ordered after the specified rhs nullable object 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 NullableValue type. Also note that this function will fail to compile if LHS_TYPE and RHS_TYPE are not compatible. |
operator>= | If neither of the specified lhs and rhs contain a value, return true. If lhs contains a value, and rhs does not, return true. If lhs does not contains a value, rhs does, return false. Otherwise, return lhs.value >= rhs.value(). |
operator>= | Return true if the specified lhs nullable object 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). |
swap | Exchange the values of the specified a and b objects. This function provides the no-throw exception-safety guarantee if the two objects were created with the same allocator and the basic guarantee otherwise. |
::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueAccessValue | Default customization-point implementation of accessValue for bdlb::NullableAllocatedValue. |
::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueIsNull | Default customization-point implementation of isNull for bdlb::NullableAllocatedValue. |
::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueMakeValue | Default customization-point implementation of makeValue for bdlb::NullableAllocatedValue. |
::BloombergLP::bdlat_NullableValueFunctions::bdlat_nullableValueManipulateValue | Default customization-point implementation of manipulateValue for bdlb::NullableAllocatedValue. |