Quick Links: |
#include <bslstl_optional.h>
Public Member Functions | |
Optional_DataImp () BSLS_KEYWORD_NOEXCEPT | |
template<class... ARGS> | |
TYPE & | emplace (bslma::Allocator *allocator, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...) |
template<class INIT_LIST_TYPE , class... ARGS> | |
TYPE & | emplace (bslma::Allocator *allocator, std::initializer_list< INIT_LIST_TYPE > initializer_list, BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)...) |
void | reset () BSLS_KEYWORD_NOEXCEPT |
TYPE & | value () |
bool | hasValue () const BSLS_KEYWORD_NOEXCEPT |
const TYPE & | value () const |
This component-private struct
manages a value_type
object in an optional
object. This class provides an abstraction for const
value type. An optional
object may contain an object of const
type. An assignment to such an optional
object should not succeed. However, unless the optional
object itself is const
, it should be possible to change the value of the optional
object using emplace
. In order to allow for that, this class manages a non-const object of value_type
, but all the accessors return a const
adjusted reference to the managed object.
bslstl::Optional_DataImp< TYPE >::Optional_DataImp | ( | ) |
Create an empty Optional_DataImp
object.
TYPE& bslstl::Optional_DataImp< TYPE >::emplace | ( | bslma::Allocator * | allocator, | |
BSLS_COMPILERFEATURES_FORWARD_REF(ARGS) | ... | |||
) |
Create an object of StoredType
in d_buffer
using the specified allocator
and arguments and return a reference providing modifiable access to the underlying TYPE
object.
TYPE& bslstl::Optional_DataImp< TYPE >::emplace | ( | bslma::Allocator * | allocator, | |
std::initializer_list< INIT_LIST_TYPE > | initializer_list, | |||
BSLS_COMPILERFEATURES_FORWARD_REF(ARGS) | ... | |||
) |
Create an object of StoredType
in d_buffer
using the specified allocator
, initializer_list
and arguments, and return a reference providing modifiable access to the underlying TYPE
object.
void bslstl::Optional_DataImp< TYPE >::reset | ( | ) |
Destroy the value_type
object in d_buffer
, if any.
TYPE& bslstl::Optional_DataImp< TYPE >::value | ( | ) |
Return the value_type
object in d_buffer
with const qualification adjusted to match that of TYPE
. The behavior is undefined unless this->hasValue() == true
.
bool bslstl::Optional_DataImp< TYPE >::hasValue | ( | ) | const |
Return true
if this objects has a value, and false
otherwise.
const TYPE& bslstl::Optional_DataImp< TYPE >::value | ( | ) | const |
Return the value_type
object in d_buffer
with const qualification adjusted to match that of TYPE
. The behavior is undefined unless this->hasValue() == true
.