BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::NullableValue< TYPE > Class Template Reference

#include <bdlb_nullablevalue.h>

Inheritance diagram for bdlb::NullableValue< TYPE >:
bsl::optional< TYPE >

Public Types

typedef bsl::optional< TYPE > Base
 Base class of this type.
 
typedef TYPE ValueType
 
typedef AllocType allocator_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION_IF (NullableValue, bslma::UsesBslmaAllocator, bslma::UsesBslmaAllocator< TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (NullableValue, bslmf::IsBitwiseCopyable, bslmf::IsBitwiseCopyable< 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) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl NullableValue (const NullableValue &original, const allocator_type &allocator)
 
 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 bsl::nullopt_t &) BSLS_KEYWORD_NOEXCEPT
 
 NullableValue (const bsl::nullopt_t &, const allocator_type &allocator) BSLS_KEYWORD_NOEXCEPT
 
 ~NullableValue ()
 
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 bsl::nullopt_t &) 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
 Return true if this object is null, and false otherwise.
 
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
 
template<class TYPE >
 NullableValue (bslmf::MovableRef< NullableValue > original) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl
 
- Public Member Functions inherited from bsl::optional< TYPE >
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::UsesAllocatorArgT, BloombergLP::bslma::UsesBslmaAllocator< TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< TYPE >::value)
 
 optional () BSLS_KEYWORD_NOEXCEPT
 
 optional (bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
 
optional(BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
 
 optional (bsl::allocator_arg_t, AllocType allocator)
 
 optional (bsl::allocator_arg_t, AllocType allocator, bsl::nullopt_t)
 
 optional (bsl::allocator_arg_t, AllocType allocator, const optional &original)
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(t_DERIVED) original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(typename bsl::remove_reference< t_DERIVED >::type))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
 
 optional (BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl
 
 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(t_DERIVED) original, BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(typename bsl::remove_reference< t_DERIVED >::type))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, const t_ANY_TYPE &))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
 optional (bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(TYPE, t_ANY_TYPE))
 
optionaloperator= (bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
 
optionaloperator= (const TYPE &rhs)
 
optionaloperator= (BloombergLP::bslmf::MovableRef< TYPE > rhs)
 
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED (TYPE, t_DERIVED) &operator
 
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL (TYPE, const t_ANY_TYPE &) &operator
 
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL (TYPE, t_ANY_TYPE) &operator
 
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE (TYPE, t_ANY_TYPE) &operator
 
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE (TYPE, t_ANY_TYPE) &operator
 

Friends

template<class ANY_TYPE >
class NullableValue
 

Detailed Description

template<class TYPE>
class bdlb::NullableValue< TYPE >

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.

See bdlb_nullablevalue

Member Typedef Documentation

◆ allocator_type

template<class TYPE >
typedef AllocType bdlb::NullableValue< TYPE >::allocator_type

The type of allocator used by this object. If TYPE is not allocator aware, allocator_type is a private non-allocator type that effectively removes the allocator-specific constructors from consideration during overload resolution.

◆ Base

template<class TYPE >
typedef bsl::optional<TYPE> bdlb::NullableValue< TYPE >::Base

◆ ValueType

template<class TYPE >
typedef TYPE bdlb::NullableValue< 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.

Constructor & Destructor Documentation

◆ NullableValue() [1/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( )
inline

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.

◆ NullableValue() [2/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const allocator_type allocator)
inlineexplicit

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.

◆ NullableValue() [3/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const NullableValue< TYPE > &  original)
inline

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.

◆ NullableValue() [4/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const NullableValue< TYPE > &  original,
const allocator_type allocator 
)
inline

Create a nullable object having the same value as the specified original object by moving the contents of original to the newly-created object. If TYPE takes an optional allocator at construction, the allocator associated with original is propagated for use in the newly-created object. original is left in a valid but unspecified state. Create a nullable object that has the value of the specified original object and 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.

◆ NullableValue() [5/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( bslmf::MovableRef< NullableValue< TYPE > >  original,
const allocator_type allocator 
)
inline

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.

◆ NullableValue() [6/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

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.

◆ NullableValue() [7/18]

template<class TYPE >
template<class BDE_OTHER_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() 
)
inline

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.

◆ NullableValue() [8/18]

template<class TYPE >
template<class BDE_OTHER_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() 
)
inline

◆ NullableValue() [9/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

◆ NullableValue() [10/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

◆ NullableValue() [11/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

◆ NullableValue() [12/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

◆ NullableValue() [13/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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() 
)
inline

◆ NullableValue() [14/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const NullableValue< BDE_OTHER_TYPE > &  original)
inlineexplicit

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 andBDE_OTHER_TYPE' are not compatible.

◆ NullableValue() [15/18]

template<class TYPE >
template<class BDE_OTHER_TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const NullableValue< BDE_OTHER_TYPE > &  original,
const allocator_type allocator 
)
inline

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.

◆ NullableValue() [16/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const bsl::nullopt_t )
inline

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.

◆ NullableValue() [17/18]

template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( const bsl::nullopt_t ,
const allocator_type allocator 
)
inline

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.

◆ ~NullableValue()

template<class TYPE >
bdlb::NullableValue< TYPE >::~NullableValue ( )

◆ NullableValue() [18/18]

template<class TYPE >
template<class TYPE >
bdlb::NullableValue< TYPE >::NullableValue ( bslmf::MovableRef< NullableValue< TYPE > >  original)
inline

Member Function Documentation

◆ addressOr()

template<class TYPE >
const TYPE * bdlb::NullableValue< TYPE >::addressOr ( const TYPE *  address) const
inline

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.

◆ bdexStreamIn()

template<class TYPE >
template<class STREAM >
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.

◆ bdexStreamOut()

template<class TYPE >
template<class STREAM >
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.

◆ BSLMF_NESTED_TRAIT_DECLARATION()

template<class TYPE >
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION ( NullableValue< TYPE >  ,
bdlb::HasPrintMethod   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [1/3]

template<class TYPE >
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( NullableValue< TYPE >  ,
bslma::UsesBslmaAllocator  ,
bslma::UsesBslmaAllocator< TYPE >::value   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [2/3]

template<class TYPE >
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( NullableValue< TYPE >  ,
bslmf::IsBitwiseCopyable  ,
bslmf::IsBitwiseCopyable< TYPE >::value   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [3/3]

template<class TYPE >
bdlb::NullableValue< TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( NullableValue< TYPE >  ,
bslmf::IsBitwiseMoveable  ,
bslmf::IsBitwiseMoveable< TYPE >::value   
)

◆ isNull()

template<class TYPE >
bool bdlb::NullableValue< TYPE >::isNull ( ) const
inline

◆ makeValue() [1/2]

template<class TYPE >
TYPE & bdlb::NullableValue< TYPE >::makeValue ( )
inline

Assign to this object the default value for TYPE, and return a reference providing modifiable access to the underlying TYPE object.

◆ makeValue() [2/2]

template<class TYPE >
template<class BDE_OTHER_TYPE >
TYPE & bdlb::NullableValue< TYPE >::makeValue ( BSLS_COMPILERFEATURES_FORWARD_REF(BDE_OTHER_TYPE)  value)
inline

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 andBDE_OTHER_TYPE` are not compatible.

◆ makeValueInplace()

template<class TYPE >
template<class... ARGS>
TYPE & bdlb::NullableValue< TYPE >::makeValueInplace ( ARGS &&...  args)
inline

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() [1/2]

template<class TYPE >
int bdlb::NullableValue< TYPE >::maxSupportedBdexVersion ( ) const
inline

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.)

◆ maxSupportedBdexVersion() [2/2]

template<class TYPE >
int bdlb::NullableValue< TYPE >::maxSupportedBdexVersion ( int  versionSelector) const
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.

◆ operator=() [1/10]

template<class TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( bslmf::MovableRef< NullableValue< TYPE > >  rhs)
inline

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.

◆ operator=() [2/10]

template<class TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( bslmf::MovableRef< TYPE >  rhs)
inline

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.

◆ operator=() [3/10]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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 andBDE_OTHER_TYPE' are not compatible.

◆ operator=() [4/10]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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 andBDE_OTHER_TYPE' are not compatible.

◆ operator=() [5/10]

template<class TYPE >
template<class BDE_OTHER_TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( const BDE_OTHER_TYPE &  rhs)
inline

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.

◆ operator=() [6/10]

template<class TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( const bsl::nullopt_t )
inline

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.

◆ operator=() [7/10]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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 andBDE_OTHER_TYPE' are not compatible.

◆ operator=() [8/10]

template<class TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( const NullableValue< TYPE > &  rhs)
inline

Assign to this object the value of the specified rhs, and return a reference providing modifiable access to this object.

◆ operator=() [9/10]

template<class TYPE >
template<class BDE_OTHER_TYPE >
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 andBDE_OTHER_TYPE' are not compatible.

◆ operator=() [10/10]

template<class TYPE >
NullableValue< TYPE > & bdlb::NullableValue< TYPE >::operator= ( const TYPE &  rhs)
inline

Assign to this object the value of the specified rhs, and return a reference providing modifiable access to this object.

◆ print()

template<class TYPE >
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.

◆ value() [1/2]

template<class TYPE >
TYPE & bdlb::NullableValue< TYPE >::value ( )
inline

Return a reference providing modifiable access to the underlying TYPE object. The behavior is undefined unless this object is non-null.

◆ value() [2/2]

template<class TYPE >
const TYPE & bdlb::NullableValue< TYPE >::value ( ) const
inline

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.

◆ valueOr() [1/2]

template<class TYPE >
TYPE bdlb::NullableValue< TYPE >::valueOr ( const TYPE &  value) const
inline

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.

◆ valueOr() [2/2]

template<class TYPE >
const TYPE * bdlb::NullableValue< TYPE >::valueOr ( const TYPE *  value) const
inline
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.

◆ valueOrNull()

template<class TYPE >
const TYPE * bdlb::NullableValue< TYPE >::valueOrNull ( ) const
inline

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.

Friends And Related Symbol Documentation

◆ NullableValue

template<class TYPE >
template<class ANY_TYPE >
friend class NullableValue
friend

The documentation for this class was generated from the following file: