BDE 4.14.0 Production release
|
#include <bslstl_optional.h>
Public Types | |
typedef t_TYPE | value_type |
typedef bsl::allocator< char > | allocator_type |
Public Member Functions | |
BSLMF_NESTED_TRAIT_DECLARATION (Optional_Base, BloombergLP::bslma::UsesBslmaAllocator) | |
BSLMF_NESTED_TRAIT_DECLARATION (Optional_Base, BloombergLP::bslmf::UsesAllocatorArgT) | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (Optional_Base, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value) | |
BSLMF_NESTED_TRAIT_DECLARATION_IF (Optional_Base, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value) | |
template<class... t_ARGS> | |
t_TYPE & | emplace (BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args) |
void | reset () BSLS_KEYWORD_NOEXCEPT |
Optional_Base & | operator= (const Optional_Base &rhs) |
Optional_Base & | operator= (BloombergLP::bslmf::MovableRef< Optional_Base > rhs) |
t_TYPE * | operator-> () |
t_TYPE & | operator* () |
allocator_type | get_allocator () const BSLS_KEYWORD_NOEXCEPT |
Return allocator used for construction of value_type . | |
bool | has_value () const BSLS_KEYWORD_NOEXCEPT |
Return false if this object is disengaged, and true otherwise. | |
const t_TYPE & | value () const |
const t_TYPE * | operator-> () const |
const t_TYPE & | operator* () const |
template<class t_ANY_TYPE > | |
t_TYPE | value_or (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const |
operator UnspecifiedBool () const BSLS_NOTHROW_SPEC | |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_ConstructFromForwardRef, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) | |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR(t_TYPE, t_ANY_TYPE)) | |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(t_TYPE, t_ANY_TYPE)) | |
Public Attributes | |
void swap(Optional_Base &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl t_TYPE & | value () |
Protected Types | |
typedef allocator_type | AllocType |
Protected Member Functions | |
Optional_Base () | |
Optional_Base (bsl::nullopt_t) | |
Optional_Base (const Optional_Base &original) | |
template<class t_ANY_TYPE > | |
Optional_Base(BloombergLP::bslmf::MovableRef< Optional_Base > original) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl | Optional_Base (BloombergLP::bslstl::Optional_ConstructFromForwardRef, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional, const Optional_Base< t_ANY_TYPE > &original) | |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR(t_TYPE, t_ANY_TYPE)) | |
template<class t_ANY_TYPE > | |
Optional_Base (BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(t_TYPE, t_ANY_TYPE)) | |
template<class... t_ARGS> | |
Optional_Base (bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args) | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator) | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, bsl::nullopt_t) | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, const Optional_Base &original) | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, BloombergLP::bslmf::MovableRef< Optional_Base > original) | |
template<class t_ANY_TYPE > | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, BloombergLP::bslstl::Optional_ConstructFromForwardRef, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) | |
template<class t_ANY_TYPE > | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional, const Optional_Base< t_ANY_TYPE > &original) | |
template<class t_ANY_TYPE > | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original) | |
template<class... t_ARGS> | |
Optional_Base (bsl::allocator_arg_t, allocator_type allocator, bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args) | |
template<class t_ANY_TYPE > | |
void | assignOrEmplace (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) rhs) |
t_TYPE & | dereferenceRaw () |
const t_TYPE & | dereferenceRaw () const |
This component-private class template implements the functionality of bsl::optional
. The primary template is instantiated when TYPE
is allocator-aware, and holds the allocator that is used to create the stored object.
See bslstl_optional
typedef bsl::allocator<char> bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::allocator_type |
|
protected |
typedef t_TYPE bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::value_type |
value_type
is an alias for the underlying TYPE
upon which this template class is instantiated, and represents the type of the managed object. The name is chosen so it is compatible with the std::optional
implementation.
|
inlineprotected |
Create a disengaged Optional_Base
object. Use the currently installed default allocator to supply memory.
|
inlineprotected |
Create a disengaged Optional_Base
object. Use the currently installed default allocator to supply memory.
|
inlineprotected |
|
protected |
Create an Optional_Base
object having the value of the specified original
object. Use the currently installed default allocator to supply memory. Create an Optional_Base
object whose contained value is initialized by forwarding from the specified value
. Use the currently installed default allocator to supply memory.
|
inlineprotected |
Create a disengaged Optional_Base
object if the specified original
object is disengaged, and an Optional_Base
object with the value of original.value()
converted to t_TYPE
otherwise. Use the currently installed default allocator to supply memory.
|
protected |
Create a disengaged Optional_Base
object if the specified original
object is disengaged, and an Optional_Base
object with the value of original.value()
converted to t_TYPE
otherwise. Use the currently installed default allocator to supply memory. original
is left in a valid but unspecified state.
|
protected |
Create a disengaged Optional_Base
object if the specified original
object is disengaged, and an Optional_Base
object with the value of original.value()
otherwise. This is a special case constructor where t_ANY_TYPE
is a non-const version of t_TYPE
and we use the allocator from original
to supply memory. original
is left in a valid but unspecified state.
|
inlineexplicitprotected |
Create an Optional_Base
object having the value of the (template parameter) t_TYPE
created in place using the specified args
. Use the currently installed default allocator to supply memory.
|
inlineprotected |
Create a disengaged Optional_Base
object. Use the specified allocator
to supply memory.
|
inlineprotected |
Create a disengaged Optional_Base
object. Use the specified allocator
to supply memory.
|
inlineprotected |
If the specified original
contains a value, create an Optional_Base
object whose contained value is initialized from *original
. Otherwise, create a disengaged Optional_Base
object. Use the specified allocator
to supply memory.
|
inlineprotected |
If the specified original
contains a value, create an Optional_Base
object whose contained value is initialized by moving *original
. Otherwise, create a disengaged Optional_Base
object. Use the specified allocator
to supply memory. original
is left in a valid but unspecified state.
|
inlineprotected |
Create an Optional_Base
object whose contained value is initialized by forwarding from the specified value
. Use the specified allocator
to supply memory.
|
inlineprotected |
If the specified original
contains a value, create an Optional_Base
object whose contained value is initialized from *original
, converted to t_TYPE
. Otherwise, create a disengaged Optional_Base
. Use the specified allocator
to supply memory.
|
inlineprotected |
If the specified original
contains a value, create an Optional_Base
object whose contained value is initialized by moving from *original
and converting to t_TYPE
. Otherwise, create a disengaged Optional_Base
. Use the specified allocator
to supply memory. original
is left in a valid but unspecified state.
|
inlineprotected |
Create an Optional_Base
object whose contained value is initialized from the specified args
. Use the specified allocator
to supply memory.
|
inline |
|
inline |
|
inline |
|
protected |
If *this
holds an object, assign to that object the value of the specified rhs
, converted to t_TYPE
. Otherwise, construct a held object from rhs
, converted to t_TYPE
. The allocators of *this
and rhs
remain unchanged.
bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION | ( | Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC > | , |
BloombergLP::bslma::UsesBslmaAllocator | |||
) |
bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION | ( | Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC > | , |
BloombergLP::bslmf::UsesAllocatorArgT | |||
) |
bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC > | , |
BloombergLP::bslmf::IsBitwiseCopyable | , | ||
BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value | |||
) |
bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::BSLMF_NESTED_TRAIT_DECLARATION_IF | ( | Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC > | , |
BloombergLP::bslmf::IsBitwiseMoveable | , | ||
BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value | |||
) |
|
protected |
Return a reference providing modifiable access to the underlying t_TYPE
object. The behavior is undefined if the Optional_Base
object is disengaged. Note that this function is only intended to be called by bdlb::NullableValue::value
during transition of its implementation to use 'bsl::Optional_Base. Note that ref-qualified versions of value()
are not provided because NullableValue
does not require them.
|
protected |
Return a reference providing non-modifiable access to the underlying t_TYPE
object. The behavior is undefined if the Optional_Base
object is disengaged. Note that this function is only intended to be called by bdlb::NullableValue::value
during transition of its implementation to use 'bsl::Optional_Base. Note that ref-qualified versions of value()
are not provided because NullableValue
does not require them.
|
inline |
Assign to this Optional_Base
object the value of the (template parameter) t_TYPE
created in place using the specified args
and return a reference providing modifiable access to the underlying t_TYPE
object. If this Optional_Base
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_Base
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 t_TYPE
throws an exception this object is left in a disengaged state.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return a pointer providing modifiable access to the underlying t_TYPE
object. The behavior is undefined if the Optional_Base
object is disengaged.
|
inline |
Return a pointer providing non-modifiable access to the underlying t_TYPE
object. The behavior is undefined if the Optional_Base
object is disengaged.
|
inline |
Assign to this object the value of the specified rhs
object, and return a non-const
reference to this object. The allocators of this object and rhs
both remain unchanged. The contents of rhs
are either move-constructed into or move-assigned to this object. rhs
is left in a valid but unspecified state.
|
inline |
Assign to this object the value of the specified rhs
object, and return a non-const
reference to this object.
|
inline |
Reset this object to the default constructed state (i.e., to a disengaged state).
const t_TYPE & bslstl::Optional_Base< t_TYPE, t_USES_BSLMA_ALLOC >::value | ( | ) | const |
|
inline |
|
inline |