|
BDE 4.14.0 Production release
|
#include <bdlb_nullableallocatedvalue.h>
Public Types | |
| typedef TYPE | ValueType |
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bslma::UsesBslmaAllocator) | |
| BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bslmf::IsBitwiseMoveable) | |
| BSLMF_NESTED_TRAIT_DECLARATION (NullableAllocatedValue, bdlb::HasPrintMethod) | |
| NullableAllocatedValue () | |
| NullableAllocatedValue (const bsl::allocator< char > &allocator) | |
| NullableAllocatedValue (const bsl::nullopt_t &) | |
| NullableAllocatedValue (const bsl::nullopt_t &, const bsl::allocator< char > &allocator) | |
| NullableAllocatedValue (const NullableAllocatedValue &original) | |
| NullableAllocatedValue (const NullableAllocatedValue &original, const bsl::allocator< char > &allocator) | |
| NullableAllocatedValue (const TYPE &value) | |
| NullableAllocatedValue (const TYPE &value, const bsl::allocator< char > &allocator) | |
| ~NullableAllocatedValue () | |
| Destroy this object. | |
| NullableAllocatedValue< TYPE > & | operator= (const NullableAllocatedValue &rhs) |
| NullableAllocatedValue< TYPE > & | operator= (const bsl::nullopt_t &) |
| NullableAllocatedValue< TYPE > & | operator= (const TYPE &rhs) |
| TYPE * | operator-> () |
| TYPE & | operator* () |
| template<class... ARGS> | |
| TYPE & | emplace (BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...) |
| template<class STREAM > | |
| STREAM & | bdexStreamIn (STREAM &stream, int version) |
| TYPE & | makeValue (const TYPE &val) |
| TYPE & | makeValue () |
| void | reset () |
| void | swap (NullableAllocatedValue &other) |
| TYPE & | value () |
| template<class STREAM > | |
| STREAM & | bdexStreamOut (STREAM &stream, int version) const |
| bsl::allocator< char > | get_allocator () const |
| bool | has_value () const BSLS_KEYWORD_NOEXCEPT |
| bool | isNull () const BSLS_KEYWORD_NOEXCEPT |
| int | maxSupportedBdexVersion (int versionSelector) const |
| int | maxSupportedBdexVersion () const |
| template<class ANY_TYPE > | |
| TYPE | value_or (const ANY_TYPE &default_value) const |
| const TYPE * | operator-> () const |
| const TYPE & | operator* () const |
| operator UnspecifiedBool () const BSLS_NOTHROW_SPEC | |
| bslma::Allocator * | allocator () const |
| Return the allocator used by this object to supply memory. | |
| bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
| const TYPE & | value () const |
| BSLS_DEPRECATE_FEATURE ("bdl", "NullableAllocatedValue::addressOr", "Use 'has_value() ? &value() : address' instead") const TYPE *addressOr(const TYPE *address) const | |
| template<class... ARGS> | |
| BSLS_DEPRECATE_FEATURE ("bdl", "NullableAllocatedValue::makeValueInplace", "Use 'emplace' instead") TYPE &makeValueInplace(ARGS &&... args) | |
| BSLS_DEPRECATE_FEATURE ("bdl", "NullableAllocatedValue::valueOr", "Use 'value_or' instead") TYPE valueOr(const TYPE &otherValue) const | |
| BSLS_DEPRECATE_FEATURE ("bdl", "NullableAllocatedValue::valueOrNull", "Use 'has_value() ? &value() : NULL' instead") const TYPE *valueOrNull() const | |
| template<class... ARGS> | |
| TYPE & | emplace (BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args) |
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&.
| typedef TYPE bdlb::NullableAllocatedValue< 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.
|
inline |
Create a nullable object having the null value. Use the currently installed default allocator to supply memory.
|
inlineexplicit |
Create a nullable object that has the null value and that uses the mechanism of the specified allocator to supply memory.
|
inline |
Create a nullable object having the null value. Use the currently installed default allocator to supply memory.
|
inline |
Create a nullable object that has the null value and that uses the mechanism of the specified allocator to supply memory.
|
inline |
Create a nullable object having the value of the specified original object. Use the currently installed default allocator to supply memory.
|
inline |
Create a nullable object having the value of the specified original object and that uses the mechanism of the specified allocator to supply memory.
|
inline |
Create a nullable object having the specified value. Use the currently installed default allocator to supply memory.
|
inline |
Create a nullable object having the specified value and that uses the mechanism of specified allocator to supply memory.
|
inline |
|
inline |
| STREAM & bdlb::NullableAllocatedValue< TYPE >::bdexStreamIn | ( | STREAM & | stream, |
| int | version | ||
| ) |
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.
| STREAM & bdlb::NullableAllocatedValue< TYPE >::bdexStreamOut | ( | STREAM & | stream, |
| int | version | ||
| ) | const |
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.
| bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | NullableAllocatedValue< TYPE > | , |
| bdlb::HasPrintMethod | |||
| ) |
| bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | NullableAllocatedValue< TYPE > | , |
| bslma::UsesBslmaAllocator | |||
| ) |
| bdlb::NullableAllocatedValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | NullableAllocatedValue< TYPE > | , |
| bslmf::IsBitwiseMoveable | |||
| ) |
| bdlb::NullableAllocatedValue< TYPE >::BSLS_DEPRECATE_FEATURE | ( | "bdl" | , |
| "NullableAllocatedValue< TYPE >::addressOr" | , | ||
| "Use 'has_value() ? &value() : address' instead" | |||
| ) | const |
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.
| bdlb::NullableAllocatedValue< TYPE >::BSLS_DEPRECATE_FEATURE | ( | "bdl" | , |
| "NullableAllocatedValue< TYPE >::makeValueInplace" | , | ||
| "Use 'emplace' instead" | |||
| ) | && |
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.
| bdlb::NullableAllocatedValue< TYPE >::BSLS_DEPRECATE_FEATURE | ( | "bdl" | , |
| "NullableAllocatedValue< TYPE >::valueOr" | , | ||
| "Use 'value_or' instead" | |||
| ) | const & |
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.
| bdlb::NullableAllocatedValue< TYPE >::BSLS_DEPRECATE_FEATURE | ( | "bdl" | , |
| "NullableAllocatedValue< TYPE >::valueOrNull" | , | ||
| "Use 'has_value() ? &value() : NULL' instead" | |||
| ) | const |
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.
|
inline |
| TYPE & bdlb::NullableAllocatedValue< TYPE >::emplace | ( | BSLS_COMPILERFEATURES_FORWARD_REF(ARGS) | ... | ) |
Assign to this object 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.
|
inline |
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.
|
inline |
Return true if this object contains a value, and false otherwise.
|
inline |
Return false if this object contains a value, and true otherwise. Note that this is the opposite of has_value .
|
inline |
Assign to this object the default value for TYPE, and return a reference providing modifiable access to the underlying TYPE object.
|
inline |
Assign to this object the specified val, and return a reference providing modifiable access to the underlying TYPE object.
|
inline |
Return the most current BDEX streaming version number supported by this class. (See the package-group-level documentation for more information on BDEX streaming of container types.)
|
inline |
Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that it is highly recommended that versionSelector be formatted as "YYYYMMDD", a date representation. Also note that versionSelector should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.
|
inline |
Simulation of explicit conversion to bool. Inlined to work around xlC bug when out-of-line.
|
inline |
Return a reference providing modifiable access to the underlying TYPE object. The behavior is undefined if the object has no value.
|
inline |
Return a reference providing non-modifiable access to the underlying TYPE object. The behavior is undefined if the object has no value.
|
inline |
Return a pointer providing modifiable access to the underlying TYPE object. The behavior is undefined if the object has no value.
|
inline |
Return a pointer providing non-modifiable access to the underlying TYPE object. The behavior is undefined if the object has no value.
|
inline |
Reset this object to the default constructed state (i.e., to have the null value).
|
inline |
Assign to this object the value of the specified rhs, and return a reference providing modifiable access to this object.
|
inline |
Assign to this object the value of the specified rhs, and return a reference providing modifiable access to the underlying TYPE object.
|
inline |
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.
|
inline |
Reset this object to the default constructed state (i.e., to have the null value).
| void bdlb::NullableAllocatedValue< TYPE >::swap | ( | NullableAllocatedValue< TYPE > & | other | ) |
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.
|
inline |
Return a reference providing modifiable access to the underlying TYPE object. The behavior is undefined unless this object is non-null.
|
inline |
Return a reference providing non-modifiable access to the underlying TYPE object. The behavior is undefined unless this object is non-null.
|
inline |
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.
| char bdlb::NullableAllocatedValue< TYPE >::d_buffer[sizeof(TYPE *)] |
| TYPE* bdlb::NullableAllocatedValue< TYPE >::d_pointer_p |