[#BloombergLP-bslstl-Optional_Base-05]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::Optional&lowbar;Base
:relfileprefix: ../../
:mrdocs:

This component&hyphen;private class template implements the functionality of `bsl&colon;&colon;optional`&period; The primary template is instantiated when `TYPE` is allocator&hyphen;aware, and holds the allocator that is used to create the stored object&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;optional&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;TYPE,
    bool t&lowbar;USES&lowbar;BSLMA&lowbar;ALLOC = BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;t&lowbar;TYPE&gt;&colon;&colon;value&gt;
class Optional&lowbar;Base;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Optional_Base-05/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to `bsl&colon;&colon;allocator&lt;char&gt;`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/value_type.adoc[`value&lowbar;type`] 
| `value&lowbar;type` is an alias for the underlying `TYPE` upon which this template class is instantiated, and represents the type of the managed object&period; The name is chosen so it is compatible with the `std&colon;&colon;optional` implementation&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Optional_Base-05/operator_assign-09.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bslstl/Optional_Base-05/emplace-02.adoc[`emplace`] 
| `emplace` overloads
| xref:BloombergLP/bslstl/Optional_Base-05/get_allocator.adoc[`get&lowbar;allocator`] 
| Return allocator used for construction of `value&lowbar;type`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/has_value.adoc[`has&lowbar;value`] 
| Return `false` if this object is disengaged, and `true` otherwise&period;
| xref:BloombergLP/bslstl/Optional_Base-05/operator_star-0b.adoc[`operator&ast;`] 
| Dereference operators
| xref:BloombergLP/bslstl/Optional_Base-05/operator_ptr-0a.adoc[`operator&hyphen;&gt;`] 
| Member access operators
| xref:BloombergLP/bslstl/Optional_Base-05/reset.adoc[`reset`] 
| Reset this object to the default constructed state (i&period;e&period;, to a disengaged state)&period;
| xref:BloombergLP/bslstl/Optional_Base-05/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with the value of the specified `other` object&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if the template parameter `t&lowbar;TYPE` provides that guarantee and the result of the `hasValue` method for the two objects being swapped is the same&period; The behavior is undefined unless this object was created with the same allocator as `other`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/value-07a.adoc[`value`] 
| `value` overloads
| xref:BloombergLP/bslstl/Optional_Base-05/value_or-07.adoc[`value&lowbar;or`] 
| `value&lowbar;or` overloads
| xref:BloombergLP/bslstl/Optional_Base-05/2conversion-076.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Optional&lowbar;Base, IsBitwiseCopyable, BloombergLP&colon;&colon;bslmf&colon;&colon;IsBitwiseCopyable&lt;t&lowbar;TYPE&gt;&colon;&colon;value&gt;`] 
| Nested trait declaration for `bslmf&colon;&colon;IsBitwiseCopyable`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Optional&lowbar;Base, IsBitwiseMoveable, BloombergLP&colon;&colon;bslmf&colon;&colon;IsBitwiseMoveable&lt;t&lowbar;TYPE&gt;&colon;&colon;value&gt;`] 
| Nested trait declaration for `bslmf&colon;&colon;IsBitwiseMoveable`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/2conversion-0a.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Optional&lowbar;Base, UsesAllocatorArgT&gt;`] 
| Nested trait declaration for `bslmf&colon;&colon;UsesAllocatorArgT`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/2conversion-0b.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Optional&lowbar;Base, UsesBslmaAllocator&gt;`] 
| Nested trait declaration for `bslma&colon;&colon;UsesBslmaAllocator`&period;
| xref:BloombergLP/bslstl/Optional_Base-05/2conversion-071.adoc[`operator bool`] 
| Return `false` if this object is disengaged, and `true` otherwise&period;
|===


== Protected Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Optional_Base-05/AllocType.adoc[`AllocType`] 
| This `typedef` is an alias to `allocator&lowbar;type`&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Optional_Base-05/2constructor-0f.adoc[`Optional&lowbar;Base`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslstl/Optional_Base-05/assignOrEmplace.adoc[`assignOrEmplace`] 
| If `&ast;this` holds an object, assign to that object the value of the specified `rhs`, converted to `t&lowbar;TYPE`&period; Otherwise, construct a held object from `rhs`, converted to `t&lowbar;TYPE`&period; The allocators of `&ast;this` and `rhs` remain unchanged&period;
| xref:BloombergLP/bslstl/Optional_Base-05/dereferenceRaw-049.adoc[`dereferenceRaw`] 
| `dereferenceRaw` overloads
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Optional_Base-08.adoc[`Optional&lowbar;Base&lt;t&lowbar;TYPE, false&gt;`] 
| Specialization of `Optional&lowbar;Base` for `value&lowbar;type` that is not allocator&hyphen;aware when `std&colon;&colon;optional` is available&period;
|===


== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:bsl/optional-072.adoc[`optional`] 
| 
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
