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

#include <bdlb_nullablevalueref.h>

Public Types

typedef TYPE value_type
 

Public Member Functions

 ConstNullableValueRef (const bsl::optional< TYPE > &opt)
 
 ConstNullableValueRef (const NullableAllocatedValue< TYPE > &opt)
 
 ConstNullableValueRef (const NullableValueRef< TYPE > &ref)
 
 ConstNullableValueRef (const ConstNullableValueRef &original)
 
 ~ConstNullableValueRef ()
 
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
 
 BSLS_DEPRECATE_FEATURE ("bdl", "ConstNullableValueRef::addressOr", "Use 'has_value() ? &value() : address' instead") const TYPE *addressOr(const TYPE *address) const
 
 BSLS_DEPRECATE_FEATURE ("bdl", "ConstNullableValueRef::valueOr", "Use 'value_or' instead") TYPE valueOr(const TYPE &otherValue) const
 
 BSLS_DEPRECATE_FEATURE ("bdl", "ConstNullableValueRef::valueOrNull", "Use 'has_value() ? &value() : NULL' instead") const TYPE *valueOrNull() const
 

Detailed Description

template<class TYPE>
class bdlb::ConstNullableValueRef< TYPE >

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

See bdlb_nullablevalueref

Member Typedef Documentation

◆ value_type

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

◆ ~ConstNullableValueRef()

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

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

Member Function Documentation

◆ BSLS_DEPRECATE_FEATURE() [1/3]

template<class TYPE >
bdlb::ConstNullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"ConstNullableValueRef< 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/3]

template<class TYPE >
bdlb::ConstNullableValueRef< TYPE >::BSLS_DEPRECATE_FEATURE ( "bdl"  ,
"ConstNullableValueRef< 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() [3/3]

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

◆ operator UnspecifiedBool()

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

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


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