Quick Links: |
#include <bdlb_nullablevalue.h>
Classes | |
struct | EnableType |
struct | NoAlloc |
Public Types | |
typedef bsl::optional< TYPE > | Base |
typedef TYPE | ValueType |
typedef AllocType | allocator_type |
typedef TYPE | value_type |
Public Member Functions | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (NullableValue, bslma::UsesBslmaAllocator, bslma::UsesBslmaAllocator< TYPE >::value) | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (NullableValue, bsl::is_trivially_copyable, bsl::is_trivially_copyable< TYPE >::value) | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (NullableValue, bslmf::IsBitwiseMoveable, bslmf::IsBitwiseMoveable< TYPE >::value) | |
BSLMF_NESTED_TRAIT_DECLARATION (NullableValue, bdlb::HasPrintMethod) | |
NullableValue () BSLS_KEYWORD_NOEXCEPT | |
NullableValue (const allocator_type &allocator) BSLS_KEYWORD_NOEXCEPT | |
NullableValue (const NullableValue &original) | |
NullableValue (bslmf::MovableRef< NullableValue > original, const allocator_type &allocator) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) value, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_convertible< BDE_OTHER_TYPE, allocator_type >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) value, const allocator_type &allocator, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (const bsl::optional< BDE_OTHER_TYPE > &value, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (const bsl::optional< BDE_OTHER_TYPE > &value, const allocator_type &allocator, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) value, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) value, const allocator_type &allocator, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) value, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) value, const allocator_type &allocator, typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type=EnableType()) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (const NullableValue< BDE_OTHER_TYPE > &original) | |
template<class BDE_OTHER_TYPE > | |
NullableValue (const NullableValue< BDE_OTHER_TYPE > &original, const allocator_type &allocator) | |
NullableValue (const NullOptType &) BSLS_KEYWORD_NOEXCEPT | |
NullableValue (const NullOptType &, const allocator_type &allocator) BSLS_KEYWORD_NOEXCEPT | |
NullableValue< TYPE > & | operator= (const NullableValue &rhs) |
NullableValue< TYPE > & | operator= (bslmf::MovableRef< NullableValue > rhs) |
template<class BDE_OTHER_TYPE > | |
NullableValue< TYPE > & | operator= (const NullableValue< BDE_OTHER_TYPE > &rhs) |
template<class BDE_OTHER_TYPE > | |
NullableValue< TYPE > & | operator= (BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) rhs) |
template<class BDE_OTHER_TYPE > | |
bsl::enable_if < bsl::is_convertible < BDE_OTHER_TYPE, TYPE > ::value, NullableValue< TYPE > & >::type | operator= (const bsl::optional< BDE_OTHER_TYPE > &rhs) |
template<class BDE_OTHER_TYPE > | |
bsl::enable_if < bsl::is_convertible < BDE_OTHER_TYPE, TYPE > ::value, NullableValue< TYPE > & >::type | operator= (BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) rhs) |
NullableValue< TYPE > & | operator= (const TYPE &rhs) |
NullableValue< TYPE > & | operator= (bslmf::MovableRef< TYPE > rhs) |
template<class BDE_OTHER_TYPE > | |
NullableValue< TYPE > & | operator= (const BDE_OTHER_TYPE &rhs) |
NullableValue< TYPE > & | operator= (const NullOptType &) BSLS_KEYWORD_NOEXCEPT |
template<class STREAM > | |
STREAM & | bdexStreamIn (STREAM &stream, int version) |
template<class BDE_OTHER_TYPE > | |
TYPE & | makeValue (BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) value) |
TYPE & | makeValue () |
template<class... ARGS> | |
TYPE & | makeValueInplace (ARGS &&...args) |
TYPE & | value () |
const TYPE * | addressOr (const TYPE *address) const |
template<class STREAM > | |
STREAM & | bdexStreamOut (STREAM &stream, int version) const |
bool | isNull () const BSLS_KEYWORD_NOEXCEPT |
int | maxSupportedBdexVersion (int versionSelector) const |
int | maxSupportedBdexVersion () const |
bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
const TYPE & | value () const |
TYPE | valueOr (const TYPE &value) const |
const TYPE * | valueOr (const TYPE *value) const |
const TYPE * | valueOrNull () const |
BSLMF_NESTED_TRAIT_DECLARATION (optional, BloombergLP::bslma::UsesBslmaAllocator) | |
BSLMF_NESTED_TRAIT_DECLARATION (optional, BloombergLP::bslmf::UsesAllocatorArgT) | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< TYPE >::value) | |
TYPE & | emplace (BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...) |
TYPE & | emplace (std::initializer_list< INIT_LIST_TYPE > il, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...) |
void | reset () BSLS_KEYWORD_NOEXCEPT |
TYPE * | operator-> () |
const TYPE * | operator-> () const |
TYPE & | operator* () |
const TYPE & | operator* () const |
allocator_type | get_allocator () const BSLS_KEYWORD_NOEXCEPT |
bool | has_value () const BSLS_KEYWORD_NOEXCEPT |
TYPE | value_or (BSLS_COMPILERFEATURES_FORWARD_REF(ANY_TYPE) value) const |
operator UnspecifiedBool () const BSLS_NOTHROW_SPEC | |
Public Attributes | |
void swap(optional &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl TYPE & | value () |
Protected Member Functions | |
TYPE & | dereferenceRaw () |
const TYPE & | dereferenceRaw () const |
Friends | |
class | NullableValue |
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 Nullable<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 bdlb::NullOptType
.
See Component bdlb_nullablevalue
typedef bsl::optional<TYPE> bdlb::NullableValue< TYPE >::Base |
typedef TYPE bdlb::NullableValue< TYPE >::ValueType |
typedef AllocType bdlb::NullableValue< TYPE >::allocator_type |
Reimplemented from bsl::optional< TYPE >.
typedef TYPE bsl::optional< TYPE, USES_BSLMA_ALLOC >::value_type [inherited] |
bdlb::NullableValue< TYPE >::NullableValue | ( | ) |
Create a nullable object having the null value. If TYPE
takes an optional allocator at construction, use the currently installed default allocator to supply memory.
bdlb::NullableValue< TYPE >::NullableValue | ( | const allocator_type & | allocator | ) | [explicit] |
Create a nullable object that has the null value and that uses the specified allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. Note that this constructor will not participate in overload resolution unless TYPE
is allocator aware.
bdlb::NullableValue< TYPE >::NullableValue | ( | const NullableValue< TYPE > & | original | ) |
Create a nullable object having the value of the specified original
object. If TYPE
takes an optional allocator at construction, use the currently installed default allocator to supply memory.
bdlb::NullableValue< TYPE >::NullableValue | ( | bslmf::MovableRef< NullableValue< TYPE > > | original, | |
const allocator_type & | allocator | |||
) |
Create a nullable object having the same value as the specified original
object but using the specified allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. The contents of original
are moved to the newly-created object using the extended move constructor for TYPE
. original
is left in a valid but unspecified state. Note that this constructor will not participate in overload resolution unless TYPE
is allocator aware.
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) | value, | |
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_convertible< BDE_OTHER_TYPE, allocator_type >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT: Create a nullable object having the specified value
(of BDE_OTHER_TYPE
) converted to TYPE
. If TYPE
takes an optional allocator at construction, use the currently installed default allocator to supply memory. Note that this constructor will not participate in overload resolution unless BDE_OTHER_TYPE
is convertible to TYPE
and is not convertible to allocator_type
.
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) | value, | |
const allocator_type & | allocator, | |||
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
Create a nullable object that has the specified value
(of BDE_OTHER_TYPE
) converted to TYPE
and that uses the specified allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. Note that this constructor will not participate in overload resolution unless TYPE
is allocator aware and BDE_OTHER_TYPE
is convertible to TYPE
.
bdlb::NullableValue< TYPE >::NullableValue | ( | const bsl::optional< BDE_OTHER_TYPE > & | value, | |
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | const bsl::optional< BDE_OTHER_TYPE > & | value, | |
const allocator_type & | allocator, | |||
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) | value, | |
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) | value, | |
const allocator_type & | allocator, | |||
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) | value, | |
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) | value, | |
const allocator_type & | allocator, | |||
typename bsl::enable_if< bsl::is_convertible< BDE_OTHER_TYPE, TYPE >::value &&!bsl::is_same< bsl::optional< BDE_OTHER_TYPE >, TYPE >::value, EnableType >::type | = EnableType() | |||
) |
IMPLICIT:
bdlb::NullableValue< TYPE >::NullableValue | ( | const NullableValue< BDE_OTHER_TYPE > & | original | ) | [explicit] |
Create a nullable object having the null value if the specified original
object is null, and the value of original.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. If TYPE
takes an optional allocator at construction, use the currently installed default allocator to supply memory. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
bdlb::NullableValue< TYPE >::NullableValue | ( | const NullableValue< BDE_OTHER_TYPE > & | original, | |
const allocator_type & | allocator | |||
) |
Create a nullable object that has the null value if the specified original
object is null, and the value of original.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. Use the specified allocator
(e.g., the address of a bslma::Allocator
object) to supply memory. Note that this constructor will not participate in overload resolution unless TYPE
is allocator aware. Also note that compilation will fail if this function is called with a BDE_OTHER_TYPE
that is not convertible to TYPE
.
bdlb::NullableValue< TYPE >::NullableValue | ( | const NullOptType & | ) |
IMPLICIT: Create a nullable object having the null value. If TYPE
takes an optional allocator at construction, use the currently installed default allocator to supply memory for subsequent values assigned to this object.
bdlb::NullableValue< TYPE >::NullableValue | ( | const NullOptType & | , | |
const allocator_type & | allocator | |||
) |
Create a nullable object that has the null value; use the specified allocator
(e.g., the address of a bslma::Allocator
object) to supply memory for subsequent values assigned to this object. Note that this constructor will not participate in overload resolution unless TYPE
is allocator aware.
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | NullableValue< TYPE > | , | |
bslma::UsesBslmaAllocator | , | |||
bslma::UsesBslmaAllocator< TYPE >::value | ||||
) |
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | NullableValue< TYPE > | , | |
bsl::is_trivially_copyable | , | |||
bsl::is_trivially_copyable< TYPE >::value | ||||
) |
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | NullableValue< TYPE > | , | |
bslmf::IsBitwiseMoveable | , | |||
bslmf::IsBitwiseMoveable< TYPE >::value | ||||
) |
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION | ( | NullableValue< TYPE > | , | |
bdlb::HasPrintMethod | ||||
) |
UsesBslmaAllocator
, IsBitwiseCopyable
, and IsBitwiseMoveable
are true for NullableValue
only if the corresponding trait is true for TYPE
. HasPrintMethod
is always true for NullableValue
.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | const NullableValue< TYPE > & | rhs | ) |
Assign to this object the value of the specified rhs
, and return a reference providing modifiable access to this object.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | bslmf::MovableRef< NullableValue< TYPE > > | rhs | ) |
Assign to this object the value of the specified rhs
, and return a reference providing modifiable access to this object. The contents of rhs
are either move-inserted into or move-assigned to this object. rhs
is left in a valid but unspecified state.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | const NullableValue< BDE_OTHER_TYPE > & | rhs | ) |
Assign to this object the null value if the specified rhs
object is null, and the value of rhs.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. Return a reference providing modifiable access to this object. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | BSLMF_MOVABLEREF_DEDUCE(NullableValue< BDE_OTHER_TYPE >) | rhs | ) |
Assign to this object the null value if the specified rhs
object is null, and the value of rhs.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. Return a reference providing modifiable access to this object. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
bsl::enable_if<bsl::is_convertible<BDE_OTHER_TYPE, TYPE>::value, NullableValue<TYPE>&>::type bdlb::NullableValue< TYPE >::operator= | ( | const bsl::optional< BDE_OTHER_TYPE > & | rhs | ) |
Assign to this object the null value if the specified rhs
object is null, and the value of rhs.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. Return a reference providing modifiable access to this object. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
bsl::enable_if<bsl::is_convertible<BDE_OTHER_TYPE, TYPE>::value, NullableValue<TYPE>&>::type bdlb::NullableValue< TYPE >::operator= | ( | BSLMF_MOVABLEREF_DEDUCE(bsl::optional< BDE_OTHER_TYPE >) | rhs | ) |
Assign to this object the null value if the specified rhs
object is null, and the value of rhs.value()
(of BDE_OTHER_TYPE
) converted to TYPE
otherwise. Return a reference providing modifiable access to this object. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | const TYPE & | rhs | ) |
Assign to this object the value of the specified rhs
, and return a reference providing modifiable access to this object.
Reimplemented from bsl::optional< TYPE >.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | bslmf::MovableRef< TYPE > | rhs | ) |
Assign to this object the value of the specified rhs
, and return a reference providing modifiable access to this object. The contents of rhs
are either move-inserted into or move-assigned to this object. rhs
is left in a valid but unspecified state.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | const BDE_OTHER_TYPE & | rhs | ) |
Assign to this object the value of the specified rhs
object (of BDE_OTHER_TYPE
) converted to TYPE
, and return a reference providing modifiable access to this object. Note that this method will fail to compile if TYPE
and BDE_OTHER_TYPE
are not compatible. Note that on C++03 but not in C++11 and beyond, if BDE_OTHER_TYPE
is bslmf::MovableRef<TYPE3>
and TYPE
supports moves and/or assigns from that type, a move rather than a copy may take place.
NullableValue<TYPE>& bdlb::NullableValue< TYPE >::operator= | ( | const NullOptType & | ) |
Reset this object to the default constructed state (i.e., to have the null value), and return a reference providing modifiable access to this object.
STREAM& bdlb::NullableValue< 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.
TYPE& bdlb::NullableValue< TYPE >::makeValue | ( | BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE) | value | ) |
Assign to this object the specified value
(of BDE_OTHER_TYPE
) converted to TYPE
, and return a reference providing modifiable access to the underlying TYPE
object. Note that this method will fail to compile if TYPE and 'BDE_OTHER_TYPE
are not compatible.
TYPE& bdlb::NullableValue< TYPE >::makeValue | ( | ) |
Assign to this object the default value for TYPE
, and return a reference providing modifiable access to the underlying TYPE
object.
TYPE& bdlb::NullableValue< TYPE >::makeValueInplace | ( | ARGS &&... | args | ) |
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.
TYPE& bdlb::NullableValue< TYPE >::value | ( | ) |
Return a reference providing modifiable access to the underlying TYPE
object. The behavior is undefined unless this object is non-null.
const TYPE* bdlb::NullableValue< TYPE >::addressOr | ( | const TYPE * | address | ) | 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.
STREAM& bdlb::NullableValue< 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.
bool bdlb::NullableValue< TYPE >::isNull | ( | ) | const |
Return true
if this object is null, and false
otherwise.
int bdlb::NullableValue< TYPE >::maxSupportedBdexVersion | ( | int | versionSelector | ) | const |
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.
int bdlb::NullableValue< TYPE >::maxSupportedBdexVersion | ( | ) | const |
Return the most current BDEX streaming version number supported by this class. (See the bslx
package-level documentation for more information on BDEX streaming of value-semantic types and containers.)
bsl::ostream& bdlb::NullableValue< TYPE >::print | ( | bsl::ostream & | stream, | |
int | level = 0 , |
|||
int | spacesPerLevel = 4 | |||
) | const |
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.
const TYPE& bdlb::NullableValue< TYPE >::value | ( | ) | const |
Return a reference providing non-modifiable access to the underlying object of a (template parameter) TYPE
. The behavior is undefined unless this object is non-null.
Reimplemented from bsl::optional< TYPE >.
TYPE bdlb::NullableValue< TYPE >::valueOr | ( | const TYPE & | value | ) | const |
Return the value of the underlying object of a (template parameter) TYPE
if this object is non-null, and the specified value
otherwise. Note that this method returns by value, so may be inefficient in some contexts.
const TYPE* bdlb::NullableValue< TYPE >::valueOr | ( | const TYPE * | value | ) | const |
DEPRECATED: Use addressOr
instead.
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 value
otherwise.
const TYPE* bdlb::NullableValue< TYPE >::valueOrNull | ( | ) | 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.
bsl::optional< TYPE, USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION | ( | optional< TYPE > | , | |
BloombergLP::bslma::UsesBslmaAllocator | ||||
) | [inherited] |
bsl::optional< TYPE, USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION | ( | optional< TYPE > | , | |
BloombergLP::bslmf::UsesAllocatorArgT | ||||
) | [inherited] |
bsl::optional< TYPE, USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | optional< TYPE > | , | |
BloombergLP::bslmf::IsBitwiseMoveable | , | |||
BloombergLP::bslmf::IsBitwiseMoveable< TYPE >::value | ||||
) | [inherited] |
TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::emplace | ( | BSLS_COMPILERFEATURES_FORWARD_REF(ARGS) | ... | ) | [inherited] |
Assign to this optional
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. The allocator specified at the construction of this optional
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 a disengaged state.
TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::emplace | ( | std::initializer_list< INIT_LIST_TYPE > | il, | |
BSLS_COMPILERFEATURES_FORWARD_REF(ARGS) | ... | |||
) | [inherited] |
Assign to this optional
object the value of the (template parameter) TYPE
created in place using the specified il
and 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. The allocator specified at the construction of this optional
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 a disengaged state.
void bsl::optional< TYPE, USES_BSLMA_ALLOC >::reset | ( | ) | [inherited] |
Reset this object to the default constructed state (i.e., to a disengaged state).
TYPE* bsl::optional< TYPE, USES_BSLMA_ALLOC >::operator-> | ( | ) | [inherited] |
Return a pointer providing modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged.
const TYPE* bsl::optional< TYPE, USES_BSLMA_ALLOC >::operator-> | ( | ) | const [inherited] |
Return a pointer providing non-modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged.
TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::operator* | ( | ) | [inherited] |
Return a reference providing modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged.
const TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::operator* | ( | ) | const [inherited] |
Return a reference providing non-modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged.
allocator_type bsl::optional< TYPE, USES_BSLMA_ALLOC >::get_allocator | ( | ) | const [inherited] |
Return allocator used for construction of value_type
.
bool bsl::optional< TYPE, USES_BSLMA_ALLOC >::has_value | ( | ) | const [inherited] |
Return false
if this object is disengaged, and true
otherwise.
TYPE bsl::optional< TYPE, USES_BSLMA_ALLOC >::value_or | ( | BSLS_COMPILERFEATURES_FORWARD_REF(ANY_TYPE) | value | ) | const [inherited] |
Return a copy of the underlying object of a (template parameter) TYPE
if this object is non-null, and the specified value
converted to TYPE
otherwise. Note that this method returns by value, so may be inefficient in some contexts.
bsl::optional< TYPE, USES_BSLMA_ALLOC >::operator UnspecifiedBool | ( | ) | const [inline, inherited] |
< Simulation of explicit conversion to bool. Inlined to work around xlC bug when out-of-line.
TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::dereferenceRaw | ( | ) | [protected, inherited] |
Return a reference providing modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged. Note that this function is only intended to be called by bdlb::NullableValue::value
during transition of its implementation to use 'bsloptional. Note that ref-qualified versions of value()
are not provided because NullableValue
does not require them.
const TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::dereferenceRaw | ( | ) | const [protected, inherited] |
Return a reference providing non-modifiable access to the underlying TYPE
object. The behavior is undefined if the optional
object is disengaged. Note that this function is only intended to be called by bdlb::NullableValue::value
during transition of its implementation to use 'bsloptional. Note that ref-qualified versions of value()
are not provided because NullableValue
does not require them.
friend class NullableValue [friend] |
void swap (optional& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( bsl TYPE& bsl::optional< TYPE, USES_BSLMA_ALLOC >::value() [inherited] |
< Efficiently exchange the value of this object with the value of the specified other
object. This method provides the no-throw exception-safety guarantee if the template parameter TYPE
provides that guarantee and the result of the hasValue
method for the two objects being swapped is the same. The behavior is undefined unless this object was created with the same allocator as other
. Return a reference providing modifiable access to the underlying TYPE
object. Throws a bsl::bad_optional_access
if the optional
object is disengaged.