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

#include <bdlb_nullablevalueref.h>

Public Types

typedef TYPE value_type
 

Public Member Functions

 NullableValueRef (bsl::optional< TYPE > &opt)
 
 NullableValueRef (NullableAllocatedValue< TYPE > &opt)
 
 NullableValueRef (const NullableValueRef &original)
 
 ~NullableValueRef ()
 
bool has_value () const BSLS_KEYWORD_NOEXCEPT
 Return true if the target contains a value, and false otherwise.
 
bool isNull () const BSLS_KEYWORD_NOEXCEPT
 
const value_typevalue () const
 
const value_typeoperator-> () const
 
const value_typeoperator* () const
 
 operator UnspecifiedBool () const BSLS_NOTHROW_SPEC
 
template<class ANY_TYPE >
TYPE value_or (const ANY_TYPE &default_value) const
 
template<class... ARGS>
TYPE & emplace (BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...)
 
value_typeoperator-> ()
 
value_typeoperator* ()
 
NullableValueRef< TYPE > & operator= (const bsl::nullopt_t &)
 
NullableValueRef< TYPE > & operator= (const TYPE &rhs)
 
NullableValueRef< TYPE > & operator= (const bsl::optional< TYPE > &rhs)
 
NullableValueRef< TYPE > & operator= (const NullableAllocatedValue< TYPE > &rhs)
 
NullableValueRef< TYPE > & operator= (const NullableValueRef &rhs)
 
void reset ()
 
value_typevalue ()
 
 BSLS_DEPRECATE_FEATURE ("bdl", "NullableValueRef::addressOr", "Use 'has_value() ? &value() : address' instead") const TYPE *addressOr(const TYPE *address) const
 
template<class... ARGS>
 BSLS_DEPRECATE_FEATURE ("bdl", "NullableValueRef::makeValueInplace", "Use 'emplace' instead") TYPE &makeValueInplace(ARGS &&... args)
 
 BSLS_DEPRECATE_FEATURE ("bdl", "NullableValueRef::valueOr", "Use 'value_or' instead") TYPE valueOr(const TYPE &otherValue) const
 
 BSLS_DEPRECATE_FEATURE ("bdl", "NullableValueRef::valueOrNull", "Use 'has_value() ? &value() : NULL' instead") const TYPE *valueOrNull() const
 
template<class... ARGS>
TYPE & emplace (BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args)
 

Friends

class ConstNullableValueRef< TYPE >
 

Detailed Description

template<class TYPE>
class bdlb::NullableValueRef< TYPE >

This class is a wrapper for either a bsl::optional or NullableAllocatedValue, and provides modifiable access to the wrapped object.

See bdlb_nullablevalueref

Member Typedef Documentation

◆ value_type

template<class TYPE >
typedef TYPE bdlb::NullableValueRef< TYPE >::value_type

value_type is an alias for the template parameter TYPE, and represents the type of the object managed by the wrapped nullable object.

Constructor & Destructor Documentation

◆ ~NullableValueRef()

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

Destroy this object. Note that this destructor is generated by the compiler, and does not destroy the target.

Member Function Documentation

◆ BSLS_DEPRECATE_FEATURE() [1/4]

template<class TYPE >
bdlb::NullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"NullableValueRef< 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.

◆ BSLS_DEPRECATE_FEATURE() [2/4]

template<class TYPE >
template<class... ARGS>
bdlb::NullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"NullableValueRef< 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.

◆ BSLS_DEPRECATE_FEATURE() [3/4]

template<class TYPE >
bdlb::NullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"NullableValueRef< 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.

◆ BSLS_DEPRECATE_FEATURE() [4/4]

template<class TYPE >
bdlb::NullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"NullableValueRef< 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.

◆ emplace()

template<class TYPE >
template<class... ARGS>
TYPE & bdlb::NullableValueRef< TYPE >::emplace ( BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)  ...)

Assign to the target the value of the (template parameter) TYPE created in place using the specified args and return a reference providing modifiable access to the underlying TYPE object. If this optional object already contains an object (true == hasValue()), that object is destroyed before the new object is created. Note that if the constructor of TYPE throws an exception this object is left in a disengaged state.

◆ operator UnspecifiedBool()

template<class TYPE >
bdlb::NullableValueRef< TYPE >::operator UnspecifiedBool ( ) const
inline

Simulation of explicit conversion to bool. Inlined to work around xlC but when out-of-line.

Friends And Related Symbol Documentation

◆ ConstNullableValueRef< TYPE >

template<class TYPE >
friend class ConstNullableValueRef< TYPE >
friend

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