BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsl::optional< t_TYPE > Class Template Reference
Inheritance diagram for bsl::optional< t_TYPE >:
bdlb::NullableValue< balb::Choice1 > bdlb::NullableValue< balb::Choice3 > bdlb::NullableValue< double > bdlb::NullableValue< bsl::basic_string > bdlb::NullableValue< Enumerated::Value > bdlb::NullableValue< bool > bdlb::NullableValue< bsl::vector< char > > bdlb::NullableValue< bdlt::DatetimeTz > bdlb::NullableValue< balb::CustomString > bdlb::NullableValue< int > bdlb::NullableValue< unsigned int > bdlb::NullableValue< unsigned char > bdlb::NullableValue< balb::CustomInt > bdlb::NullableValue< balb::SequenceWithAnonymityChoice2 > bdlb::NullableValue< s_baltst::MySequenceWithNillableIntSequenceArraySequence > bdlb::NullableValue< s_baltst::MySequenceWithNillableStringSequenceArraySequence > bdlb::NullableValue< s_baltst::MySequence > bdlb::NullableValue< s_baltst::MySequenceWithNullableAnonymousChoiceChoice > bdlb::NullableValue< bdldfp::Decimal_Type64 > bdlb::NullableValue< s_baltst::Choice1 > bdlb::NullableValue< s_baltst::Choice3 > bdlb::NullableValue< s_baltst::CustomString > bdlb::NullableValue< s_baltst::Enumerated::Value > bdlb::NullableValue< s_baltst::CustomInt > bdlb::NullableValue< s_baltst::SequenceWithAnonymityChoice2 >

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::UsesAllocatorArgT, BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value)
 
 BSLMF_NESTED_TRAIT_DECLARATION_IF (optional, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value)
 
BSLSTL_OPTIONAL_CONSTEXPR17 optional () BSLS_KEYWORD_NOEXCEPT
 
BSLSTL_OPTIONAL_CONSTEXPR17 optional (bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
 
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
optional(BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl BSLSTL_OPTIONAL_CONSTEXPR17 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
BSLSTL_OPTIONAL_CONSTEXPR17 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class... t_ARGS>
BSLSTL_OPTIONAL_CONSTEXPR17 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)
 
template<class t_DERIVED >
 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))
 
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class 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(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class 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(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class... t_ARGS>
 optional (bsl::allocator_arg_t, AllocType allocator, bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
 
BSLSTL_OPTIONAL_CONSTEXPR20 optionaloperator= (bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
 
template<class t_DERIVED >
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED (t_TYPE, t_DERIVED) &operator
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL (t_TYPE, const t_ANY_TYPE &) &operator
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL (t_TYPE, t_ANY_TYPE) &operator
 
optionaloperator= (const t_TYPE &rhs)
 
optionaloperator= (BloombergLP::bslmf::MovableRef< t_TYPE > rhs)
 
template<class t_ANY_TYPE >
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE (t_TYPE, t_ANY_TYPE) &operator
 
template<class t_ANY_TYPE >
 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE (t_TYPE, t_ANY_TYPE) &operator
 
template<class t_DERIVED >
 optional (BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 optional (BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional (BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_DERIVED >
 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))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class t_ANY_TYPE >
 optional (bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
 
template<class 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(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 
template<class 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(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
 

Constructor & Destructor Documentation

◆ optional() [1/34]

template<class t_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( )

Create a disengaged optional object. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

◆ optional() [2/34]

template<class t_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( bsl::nullopt_t  )

Create a disengaged optional object. Use the currently installed default allocator to supply memory. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

◆ optional() [3/34]

template<class t_TYPE >
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
optional(BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

If the optional base class of the specified original holds a value, create an optional object whose contained value is initialized by moving from that value; otherwise, create a disengaged optional object. The allocator associated with the optional base class of original is propagated for use in the newly-created object. original is left in a valid, but unspecified state.

Note
Note that this constructor does not participate in overload resolution unless optional is an accessible base class of t_DERIVED or t_DERIVED is optional itself (in which case the instantiation provides the move constructor in C++03; a move constructor is implicitly declared in C++11). Create an optional object whose contained value is initialized by forwarding from the specified value. Use the currently installed default allocator to supply memory.
Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE and is implicit only when t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

◆ optional() [4/34]

template<class t_TYPE >
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)
explicit

◆ optional() [5/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() converted to t_TYPE otherwise. Use the currently installed default allocator to supply memory.

Note
Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

◆ optional() [6/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)
explicit

◆ optional() [7/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() moved and converted to t_TYPE otherwise. Use the allocator from original to supply memory if t_ANY_TYPE is a non-const version of t_TYPE; otherwise, use the currently installed default allocator. original is left in a valid but unspecified state.

Note
Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE. This constructor can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

◆ optional() [8/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)
explicit

◆ optional() [9/34]

template<class t_TYPE >
template<class... t_ARGS>
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( bsl::in_place_t  ,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)...  args 
)
explicit

Create an optional 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. This constructor can be called in constant expressions only when t_TYPE is not allocator-aware.

◆ optional() [10/34]

template<class t_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator 
)

Create a disengaged optional object. Use the specified allocator to supply memory.

◆ optional() [11/34]

template<class t_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
bsl::nullopt_t   
)

Create a disengaged optional object. Use the specified allocator to supply memory.

◆ optional() [12/34]

template<class t_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
const optional< t_TYPE > &  original 
)

If the specified original contains a value, create an optional object whose contained value is initialized from *original; otherwise, create a disengaged optional object. Use the specified allocator to supply memory.

◆ optional() [13/34]

template<class t_TYPE >
template<class t_DERIVED >
bsl::optional< t_TYPE >::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)   
)

If the optional base class of the specified original holds a value, create an optional object whose contained value is initialized by moving from that value; otherwise, create a disengaged optional object. Use the specified allocator to supply memory. original is left in a valid, but unspecified state.

Note
Note that this constructor does not participate in overload resolution unless optional is an accessible base class of t_DERIVED or t_DERIVED is optional itself (in which case the instantiation provides the allocator-extended move constructor).

◆ optional() [14/34]

template<class t_TYPE >
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

Create an optional object whose contained value is initialized by forwarding from the specified value. Use the specified allocator to supply memory.

Note
Note that this constructor participates in overload resolution only when t_TYPE is constructible from t_ANY_TYPE, and is implicit only when t_ANY_TYPE is implicitly convertible to t_TYPE.

◆ optional() [15/34]

template<class t_TYPE >
template<class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG>
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)
explicit

◆ optional() [16/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() converted to t_TYPE otherwise. Use the specified allocator to supply memory.

Note
Note that this constructor participates in overload resolution only when t_TYPE is constructible from an lvalue of const t_ANY_TYPE, and is implicit only when an lvalue of const t_ANY_TYPE is implicitly convertible to t_TYPE.

◆ optional() [17/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)
explicit

◆ optional() [18/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

Create a disengaged optional object if the specified original object is disengaged, and an optional object with the value of original.value() moved and converted to t_TYPE otherwise. Use the specified allocator to supply memory. original is left in a valid but unspecified state.

Note
Note that this constructor participates in overload resolution only when t_TYPE is constructible from an xvalue of t_ANY_TYPE, and is implicit only when an xvalue of t_ANY_TYPE is implicitly convertible to t_TYPE.

◆ optional() [19/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)
explicit

◆ optional() [20/34]

template<class t_TYPE >
template<class... t_ARGS>
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
bsl::in_place_t  ,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)...  args 
)
explicit

Create an optional object having the value of the (template parameter) t_TYPE created in place using the specified args. Use the specified allocator to supply memory.

◆ optional() [21/34]

template<class t_TYPE >
template<class t_DERIVED >
bsl::optional< t_TYPE >::optional ( BloombergLP::bslmf::MovableRef< t_DERIVED >  original,
BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)   
)

◆ optional() [22/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [23/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR17 bsl::optional< t_TYPE >::optional ( BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [24/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

◆ optional() [25/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

◆ optional() [26/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [27/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::optional ( BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [28/34]

template<class t_TYPE >
template<class t_DERIVED >
bsl::optional< t_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() [29/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [30/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE)  value,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [31/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

◆ optional() [32/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
const optional< t_ANY_TYPE > &  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &)   
)

◆ optional() [33/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

◆ optional() [34/34]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::optional ( bsl::allocator_arg_t  ,
AllocType  allocator,
BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >)  original,
BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE)  ,
BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE)   
)

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [1/4]

template<class t_TYPE >
bsl::optional< t_TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( optional< t_TYPE >  ,
BloombergLP::bslma::UsesBslmaAllocator  ,
BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [2/4]

template<class t_TYPE >
bsl::optional< t_TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( optional< t_TYPE >  ,
BloombergLP::bslmf::IsBitwiseCopyable  ,
BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [3/4]

template<class t_TYPE >
bsl::optional< t_TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( optional< t_TYPE >  ,
BloombergLP::bslmf::IsBitwiseMoveable  ,
BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value   
)

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF() [4/4]

template<class t_TYPE >
bsl::optional< t_TYPE >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( optional< t_TYPE >  ,
BloombergLP::bslmf::UsesAllocatorArgT  ,
BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value   
)

◆ BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE() [1/2]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE ( t_TYPE  ,
t_ANY_TYPE   
) &

Assign to this object the value of the specified rhs object (of ANY_TYPE) converted to TYPE, and return a reference providing modifiable access to this object.

Note
Note that this method may invoke assignment from rhs, or construction from rhs, depending on whether this optional object is engaged.

◆ BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE() [2/2]

template<class t_TYPE >
template<class t_ANY_TYPE >
bsl::optional< t_TYPE >::BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE ( t_TYPE  ,
t_ANY_TYPE   
) &

◆ BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL() [1/2]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL ( t_TYPE  ,
const t_ANY_TYPE &   
) &

Disengage this object if the specified rhs object is disengaged, and assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object.

Note
Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

◆ BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL() [2/2]

template<class t_TYPE >
template<class t_ANY_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 bsl::optional< t_TYPE >::BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL ( t_TYPE  ,
t_ANY_TYPE   
) &

Disengage this object if the specified rhs object is disengaged, and move assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object.

Note
Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator-aware.

◆ BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED()

template<class t_TYPE >
template<class t_DERIVED >
bsl::optional< t_TYPE >::BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED ( t_TYPE  ,
t_DERIVED   
) &

If the optional base class of the specified rhs holds a value, move-construct or move-assign the contained value of *this from that value. Otherwise, set *this to be disengaged. Return a reference providing modifiable access to this object. rhs is left in a valid but unspecified state. This method does not participate in overload resolution unless optional is an accessible base class of t_DERIVED or t_DERIVED is optional itself (in which case the instantiation provides the move assignment operator in C++03; a move assignment operator is implicitly declared in C++11).

◆ operator=() [1/3]

template<class t_TYPE >
optional< t_TYPE > & bsl::optional< t_TYPE >::operator= ( BloombergLP::bslmf::MovableRef< t_TYPE >  rhs)

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-constructed into or move-assigned to this object. rhs is left in a valid but unspecified state.

◆ operator=() [2/3]

template<class t_TYPE >
BSLSTL_OPTIONAL_CONSTEXPR20 optional< t_TYPE > & bsl::optional< t_TYPE >::operator= ( bsl::nullopt_t  )

Reset this object to be disengaged and return a reference providing modifiable access to this object. This assignment operator can be called in constant expressions only when t_TYPE is not allocator-aware.

◆ operator=() [3/3]

template<class t_TYPE >
optional< t_TYPE > & bsl::optional< t_TYPE >::operator= ( const t_TYPE &  rhs)

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


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