BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_optional_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_optional_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_optional_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_OPTIONAL_CPP03
12#define INCLUDED_BSLSTL_OPTIONAL_CPP03
13
14/// @defgroup bslstl_optional_cpp03 bslstl_optional_cpp03
15/// @brief Provide C++03 implementation for bslstl_optional.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_optional_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_optional_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_optional_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_optional_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_optional_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_optional.h
30///
31/// # Classes {#bslstl_optional_cpp03-classes}
32/// See bslstl_optional.h for list of classes
33///
34/// @see bslstl_optional
35///
36/// # Description {#bslstl_optional_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Tue Apr 28 12:08:43 2026
48/// Command line: sim_cpp11_features.pl bslstl_optional.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_optional_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_OPTIONAL_H
64
65// ============================================================================
66// Section: BSLSTL_OPTIONAL_* Macros
67// ============================================================================
68
69#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \
70 !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \
71 (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17))
72
73/// The following macro `BSLSTL_OPTIONAL_USES_STD_ALIASES` controls whether
74/// platform standard library is used as a basis for `bsl` types in the
75/// following ways:
76/// - `bsl::nullopt` is an alias to `std::nullopt`
77///
78/// - `bsl::optional<T>` inherits from `std::optional<T>` when `T` is not
79/// allocator-aware.
80///
81/// This macro does *not* control whether there are conversions and comparisons
82/// between `std::optional` and `bsl::optional`, that is conditioned only on
83/// whether `std::optional` is available (i.e.,
84/// `BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY` is defined).
85# define BSLSTL_OPTIONAL_USES_STD_ALIASES
86
87/// `BSLSTL_OPTIONAL_CONSTEXPR17` controls whether constructors that are
88/// `constexpr` in C++17 `std::optional` are `constexpr` in `bsl::optional`
89/// for allocator-unaware types.
90# define BSLSTL_OPTIONAL_CONSTEXPR17 constexpr
91
92/// `BSLSTL_OPTIONAL_CONSTEXPR20` controls whether constructors that are
93/// `constexpr` in C++20 `std::optional` are `constexpr` in `bsl::optional`
94/// for allocator-unaware types.
95# ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY
96# define BSLSTL_OPTIONAL_CONSTEXPR20 BSLS_KEYWORD_CONSTEXPR_CPP20
97# else
98# define BSLSTL_OPTIONAL_CONSTEXPR20
99# endif
100#else
101# define BSLSTL_OPTIONAL_CONSTEXPR17
102# define BSLSTL_OPTIONAL_CONSTEXPR20
103#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY & not disabled
104
105# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
106
107// This macro is defined as 'std::is_constructible<U, V>::value' in C++11 and
108// later, and as 'DEFAULT' in C++03 with the value of 'DEFAULT' typically
109// chosen to not affect the constraint this macro appears in. Note that
110// 'is_constructible', unlike 'is_convertible', is 'true' for both implicitly
111// and explicitly constructible conversions.
112#define BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(U, V, DEFAULT) \
113 std::is_constructible<U, V>::value
114
115// This macro is defined as 'std::is_assignable<U, V>::value' in C++11 and
116// later, and as 'DEFAULT' in C++03 with the value of 'DEFAULT' typically
117// chosen to not affect the constraint this macro appears in.
118#define BSLSTL_OPTIONAL_IS_ASSIGNABLE(U, V, DEFAULT) \
119 std::is_assignable<U, V>::value
120
121# else // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
122
123#define BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(U, V, DEFAULT) DEFAULT
124
125#define BSLSTL_OPTIONAL_IS_ASSIGNABLE(U, V, DEFAULT) DEFAULT
126
127# endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY else
128
129// As in 'std' implementation, if the 'TYPE' converts from any value category
130// of an optional type 'OPT_TYPE', we consider it convertible from that
131// optional type.
132#define BSLSTL_OPTIONAL_CONVERTS_FROM(TYPE, OPT_TYPE) \
133 (bsl::is_convertible<const OPT_TYPE&, TYPE>::value || \
134 bsl::is_convertible<OPT_TYPE&, TYPE>::value || \
135 bsl::is_convertible<const OPT_TYPE, TYPE>::value || \
136 bsl::is_convertible<OPT_TYPE, TYPE>::value || \
137 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, const OPT_TYPE&, false) || \
138 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, OPT_TYPE&, false) || \
139 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, const OPT_TYPE, false) || \
140 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, OPT_TYPE, false))
141
142// As in 'std' implementation, if the 'TYPE' can be assigned to from any value
143// category of an optional type 'OPT_TYPE', we consider it convertible from
144// that optional type.
145# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
146#define BSLSTL_OPTIONAL_ASSIGNS_FROM(TYPE, OPT_TYPE) \
147 (std::is_assignable<TYPE&, const OPT_TYPE&>::value || \
148 std::is_assignable<TYPE&, OPT_TYPE&>::value || \
149 std::is_assignable<TYPE&, const OPT_TYPE>::value || \
150 std::is_assignable<TYPE&, OPT_TYPE>::value)
151
152# else // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
153// The value of this macro is chosen so it does not affect the disjunction-form
154// constraint this macro appears in.
155#define BSLSTL_OPTIONAL_ASSIGNS_FROM(TYPE, OPT_TYPE) false
156# endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY else
157
158#define BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
159 BSLSTL_OPTIONAL_CONVERTS_FROM( \
160 TYPE, \
161 bsl::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
162
163#define BSLSTL_OPTIONAL_ASSIGNS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
164 BSLSTL_OPTIONAL_ASSIGNS_FROM( \
165 TYPE, \
166 bsl::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
167
168# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
169#define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
170 BSLSTL_OPTIONAL_CONVERTS_FROM( \
171 TYPE, \
172 std::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
173
174#define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
175 BSLSTL_OPTIONAL_ASSIGNS_FROM( \
176 TYPE, \
177 std::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
178# else // BSLSTL_OPTIONAL_USES_STD_ALIASES
179// The value of these macros is chosen to not affect the constraints these
180// macros appears in.
181#define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false
182#define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false
183
184# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else
185
186// Macros to define common constraints that enable a constructor or assignment
187// operator.
188#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, \
189 ANY_TYPE) \
190 typename bsl::enable_if< \
191 !bsl::is_same<TYPE, ANY_TYPE>::value && \
192 !BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) && \
193 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true), \
194 BloombergLP::bslstl::Optional_OptNoSuchType>::type
195
196#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, \
197 ANY_TYPE) \
198 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL( \
199 TYPE, \
200 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
201
202#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, \
203 ANY_TYPE) \
204 typename bsl::enable_if< \
205 !BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) && \
206 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true), \
207 BloombergLP::bslstl::Optional_OptNoSuchType>::type
208
209#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, \
210 ANY_TYPE) \
211 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL( \
212 TYPE, \
213 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
214
215#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, \
216 ANY_TYPE) \
217 typename bsl::enable_if< \
218 BloombergLP::bslstl::Optional_PropagatesAllocator<TYPE, \
219 ANY_TYPE>::value, \
220 BloombergLP::bslstl::Optional_OptNoSuchType>::type
221
222#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, \
223 ANY_TYPE) \
224 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR( \
225 TYPE, \
226 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
227
228#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
229 TYPE, ANY_TYPE) \
230 typename bsl::enable_if< \
231 !BloombergLP::bslstl::Optional_PropagatesAllocator<TYPE, \
232 ANY_TYPE>::value, \
233 BloombergLP::bslstl::Optional_OptNoSuchType>::type
234
235#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
236 TYPE, ANY_TYPE) \
237 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
238 TYPE, \
239 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
240
241#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE) \
242 typename bsl::enable_if< \
243 BloombergLP::bslstl::Optional_ConstructsFromType<TYPE, \
244 ANY_TYPE>::value, \
245 BloombergLP::bslstl::Optional_OptNoSuchType>::type
246
247#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE) \
248 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM( \
249 TYPE, \
250 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
251
252#define BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(DERIVED) \
253 typename bsl::enable_if< \
254 BloombergLP::bslmf::IsAccessibleBaseOf<optional, DERIVED>::value && \
255 !bsl::is_const<DERIVED>::value, \
256 BloombergLP::bslstl::Optional_OptNoSuchType>::type
257
258#define BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(DERIVED) \
259 BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(DERIVED) = \
260 BloombergLP::bslstl::Optional_OptNoSuchType(0)
261
262#define BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(U, V) \
263 typename bsl::enable_if< \
264 !bsl::is_convertible<V, U>::value, \
265 BloombergLP::bslstl::Optional_OptNoSuchType>::type
266
267#define BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(U, V) \
268 BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT( \
269 U, \
270 V) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
271
272#define BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(U, V) \
273 typename bsl::enable_if< \
274 bsl::is_convertible<V, U>::value, \
275 BloombergLP::bslstl::Optional_OptNoSuchType>::type
276
277#define BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(U, V) \
278 BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT( \
279 U, \
280 V) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
281
282#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
283 typename bsl::enable_if< \
284 !BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) && \
285 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true) && \
286 BSLSTL_OPTIONAL_IS_ASSIGNABLE(TYPE&, ANY_TYPE, true) && \
287 !BSLSTL_OPTIONAL_ASSIGNS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE), \
288 optional<TYPE> >::type
289
290#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
291 typename bsl::enable_if< \
292 !BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) && \
293 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true) && \
294 BSLSTL_OPTIONAL_IS_ASSIGNABLE(TYPE&, ANY_TYPE, true) && \
295 !BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE), \
296 optional<TYPE> >::type
297
298# if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
299# define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED(TYPE, DERIVED) \
300 typename bsl::enable_if< \
301 BloombergLP::bslmf::IsAccessibleBaseOf<bsl::optional<TYPE>, \
302 DERIVED>::value && \
303 !bsl::is_same<bsl::optional<TYPE>, DERIVED>::value, \
304 optional<TYPE> >::type
305# endif
306
307#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_FORWARD_REF(TYPE, ANY_TYPE) \
308 typename bsl::enable_if< \
309 !bsl::is_same<bsl::optional<TYPE>, \
310 typename bsl::remove_cvref<ANY_TYPE>::type>::value && \
311 !(bsl::is_same<TYPE, \
312 typename bsl::decay<ANY_TYPE>::type>::value && \
313 std::is_scalar<TYPE>::value) && \
314 std::is_constructible<TYPE, ANY_TYPE>::value && \
315 std::is_assignable<TYPE, ANY_TYPE>::value, \
316 optional<TYPE> >::type
317
318#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE(TYPE, ANY_TYPE) \
319 typename bsl::enable_if< \
320 !::BloombergLP::bslmf::IsAccessibleBaseOf< \
321 bsl::optional<TYPE>, \
322 typename bsl::remove_cv< \
323 typename ::BloombergLP::bslmf::MovableRefUtil:: \
324 RemoveReference<ANY_TYPE>::type>::type>::value, \
325 optional<TYPE> >::type
326
327#define BSLSTL_OPTIONAL_ENABLE_IF_NOT_ALLOCATOR_TAG(ARG) \
328 typename bsl::enable_if< \
329 !bsl::is_same< \
330 typename bsl::remove_cvref<ARG>::type, \
331 bsl::allocator_arg_t>::value, \
332 optional<t_TYPE> >::type
333
334#ifdef BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS
335 #define BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(ARG) = ARG
336#else
337 #define BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(ARG)
338#endif
339
340#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
341 #define BSLSTL_OPTIONAL_REQUIRES(EXPR) requires(EXPR)
342#else
343 #define BSLSTL_OPTIONAL_REQUIRES(EXPR)
344#endif
345
346
347namespace bslstl {
348/// This trivial tag type is used to create `nullopt_t` objects prior to
349/// C++17.
350///
351/// See @ref bslstl_optional_cpp03
352struct Optional_NulloptConstructToken {
353};
354} // close package namespace
355
356
357namespace bsl {
358
359# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
360
361using nullopt_t = std::nullopt_t;
362using std::nullopt;
363
364# else // BSLSTL_OPTIONAL_USES_STD_ALIASES
365
366 // ================
367 // struct nullopt_t
368 // ================
369
370/// This trivial tag type is used to create `optional` objects in a disengaged
371/// state. It uses a constructor template to avoid being constructible from
372/// any braced list. See implementation notes for more information.
373///
374/// See @ref bslstl_optional_cpp03
375struct nullopt_t {
376
377 // CREATORS
378
379 /// Create a `nullopt_t` object.
380 /// \note Note that the argument is not used.
381 template <class t_TYPE>
383 t_TYPE,
384 typename enable_if<is_same<t_TYPE,
385 BloombergLP::bslstl::
386 Optional_NulloptConstructToken>::value,
387 int>::type = 0) BSLS_KEYWORD_NOEXCEPT
388 {
389 }
390};
391
392/// Value of type `nullopt_t` used as an argument to functions that take a
393/// `nullopt_t` argument.
394# if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES)
395inline constexpr
396nullopt_t nullopt(BloombergLP::bslstl::Optional_NulloptConstructToken{});
397# else
398extern const nullopt_t nullopt;
399# endif
400
401# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
402
403template <class t_TYPE>
404class optional;
405
406} // close namespace bsl
407
408// ============================================================================
409// Section: bslstl::Optional_* Utility Classes
410// ============================================================================
411
412
413namespace bslstl {
414
415 // =============================
416 // struct Optional_IsBslOptional
417 // =============================
418
419template <class t_TYPE>
420struct Optional_IsBslOptional : bsl::false_type {
421};
422
423template <class t_TYPE>
424struct Optional_IsBslOptional<bsl::optional<t_TYPE> > : bsl::true_type {
425};
426
427 // =======================================
428 // struct Optional_IsTriviallyDestructible
429 // =======================================
430
431# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
432
433/// This metafunction is derived from
434/// `std::is_trivially_destructible<t_TYPE>` in C++11 and later. In C++03,
435/// the metafunction is derived from `bsl::is_trivially_copyable`, a trait
436/// that implies the type is also trivially destructible.
437template <class t_TYPE>
438struct Optional_IsTriviallyDestructible
439: std::is_trivially_destructible<t_TYPE> {
440};
441
442# else // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
443
444/// C++03 does not provide a trivially destructible trait. Instead we use
445/// `bslmf::IsBitwiseCopyable` which implies the type is also trivially
446/// destructible.
447///
448///
449/// \note Note that we use `bslmf::IsBitwiseCopyable` here and not
450/// `bsl::is_trivially_copyable` because on some platforms, the native
451/// `std::is_trivially_copyable<Optional_Data<t_TYPE, true>>` is `false` even
452/// though it has no dtor and `TYPE` is trivally copyable.
453template <class t_TYPE>
454struct Optional_IsTriviallyDestructible : bslmf::IsBitwiseCopyable<t_TYPE> {
455};
456
457# endif // BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY else
458
459 // ============================
460 // class Optional_OptNoSuchType
461 // ============================
462
463/// This component-private trivial tag type is used to distinguish between
464/// arguments passed by a user, and an `enable_if` argument. It is not default
465/// constructible so the following construction never invokes a constrained
466/// single parameter constructor:
467/// @code
468/// optional<SomeType> o(int, {});
469/// @endcode
470///
471/// See @ref bslstl_optional_cpp03
472struct Optional_OptNoSuchType {
473
474 // CREATORS
475
476 /// Create an `Optional_OptNoSuchType` object.
477 /// \note Note that the argument is
478 /// not used.
481};
482
483// CREATORS
484inline
487{
488}
489
490 // ==================================
491 // class Optional_PropagatesAllocator
492 // ==================================
493
494/// This metafunction is derived from `bsl::true_type` if `t_TYPE` is an
495/// allocator-aware const type, and if `t_ANY_TYPE` is the same as `t_TYPE`,
496/// minus the cv qualification. This trait is used to enable a constructor
497/// overload for a const qualified allocator-aware `ValueType` taking an rvalue
498/// of Optional_Base of the non-const qualified `ValueType`. Such an overload
499/// needs to propagate the allocator.
500template <class t_TYPE, class t_ANY_TYPE>
501struct Optional_PropagatesAllocator
503 bool,
504 bslma::UsesBslmaAllocator<t_TYPE>::value &&
505 bsl::is_const<t_TYPE>::value &&
506 bsl::is_same<t_ANY_TYPE,
507 typename bsl::remove_cv<t_TYPE>::type>::value> {
508};
509
510/// This metafunction is derived from `bsl::true_type` if `t_ANY_TYPE` is not
511/// derived from `bsl::optional<t_TYPE>`, `t_ANY_TYPE` is not a tag type, and
512/// `t_TYPE` is constructible from `t_ANY_TYPE`.
513template <class t_TYPE, class t_ANY_TYPE>
514struct Optional_ConstructsFromType
516 bool,
517 !bslmf::IsAccessibleBaseOf<
518 bsl::optional<t_TYPE>,
519 typename bsl::remove_cvref<t_ANY_TYPE>::type>::value &&
520 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
521 bsl::nullopt_t>::value &&
522 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
523 bsl::in_place_t>::value &&
524 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
525 bsl::allocator_arg_t>::value &&
526 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(t_TYPE, t_ANY_TYPE, true)> {
527};
528
529#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
530 // ===============================
531 // struct Optional_ImmovableHelper
532 // ===============================
533
534/// This struct is used to implement direct initialization of the private data
535/// member of the `std::optional` class, which makes it possible to support
536/// immovable types returned from the `transform` member function.
537///
538/// See @ref bslstl_optional_cpp03
539template <class t_TYPE, class t_INVOCABLE, class t_ARG>
540struct Optional_ImmovableHelper {
541 t_INVOCABLE&& invocable;
542 t_ARG&& arg;
543
544 operator t_TYPE()
545 {
546 return std::invoke(std::forward<t_INVOCABLE>(invocable),
547 std::forward<t_ARG>(arg));
548 }
549};
550#endif
551
552 // ===========================
553 // Component-Private Tag Types
554 // ===========================
555
556// The types defined in this section are used to select particular templated
557// constructors of 'class Optional_Base'. This avoids the need to duplicate
558// constraints between 'optional' and 'Optional_Base'.
559
560struct Optional_ConstructFromForwardRef {};
561struct Optional_CopyConstructFromOtherOptional {};
562struct Optional_MoveConstructFromOtherOptional {};
563struct Optional_CopyConstructFromStdOptional {};
564struct Optional_MoveConstructFromStdOptional {};
565
566#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
567/// Constructor tag used to implement the `transform` function.
568///
569/// See @ref bslstl_optional_cpp03
570struct Optional_InvokeConstructorTag {
571 explicit Optional_InvokeConstructorTag() = default;
572};
573#endif
574
575 // ======================
576 // class Optional_DataImp
577 // ======================
578
579/// This component-private `struct` manages a `value_type` object in an
580/// `Optional_Base` object. This class provides an abstraction for `const`
581/// value type. An `Optional_Base` object may contain an object of `const`
582/// type. An assignment to such an `Optional_Base` object should not succeed.
583/// However, unless the `Optional_Base` object itself is `const`, it should be
584/// possible to change the value of the `Optional_Base` object using `emplace`.
585/// In order to allow for that, this class manages a non-const object of
586/// `value_type`, but all the accessors return a `const` adjusted reference to
587/// the managed object.
588///
589/// See @ref bslstl_optional_cpp03
590template <class t_TYPE>
591struct Optional_DataImp {
592
593 private:
594 // PRIVATE TYPES
595 typedef typename bsl::remove_const<t_TYPE>::type StoredType;
596
597 // DATA
598
599 // in-place `TYPE` object
601
602 // `true` if object has a value, and `false` otherwise
603 bool d_hasValue;
604
605 public:
606 // CREATORS
607
608 /// Create an empty `Optional_DataImp` object.
610
611#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
612 /// Create an `Optional_DataImp` object, which contains the result of
613 /// invocation of the specified `invocable` with the specified `arg`.
614 template <class t_INVOCABLE, class t_ARG>
615 Optional_DataImp(Optional_InvokeConstructorTag ,
616 t_INVOCABLE&& invocable,
617 t_ARG&& arg);
618#endif
619
620 // MANIPULATORS
621#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
622// {{{ BEGIN GENERATED CODE
623// Command line: sim_cpp11_features.pl bslstl_optional.h
624#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
625#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
626#endif
627#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_A
628#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_A BSLSTL_OPTIONAL_VARIADIC_LIMIT
629#endif
630#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 0
631 t_TYPE& emplace(bslma::Allocator *allocator);
632#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 0
633
634#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 1
635 template <class t_ARGS_01>
636 t_TYPE& emplace(bslma::Allocator *allocator,
637 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
638#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 1
639
640#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 2
641 template <class t_ARGS_01,
642 class t_ARGS_02>
643 t_TYPE& emplace(bslma::Allocator *allocator,
644 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
645 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
646#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 2
647
648#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 3
649 template <class t_ARGS_01,
650 class t_ARGS_02,
651 class t_ARGS_03>
652 t_TYPE& emplace(bslma::Allocator *allocator,
653 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
654 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
655 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
656#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 3
657
658#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 4
659 template <class t_ARGS_01,
660 class t_ARGS_02,
661 class t_ARGS_03,
662 class t_ARGS_04>
663 t_TYPE& emplace(bslma::Allocator *allocator,
664 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
665 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
666 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
667 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
668#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 4
669
670#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 5
671 template <class t_ARGS_01,
672 class t_ARGS_02,
673 class t_ARGS_03,
674 class t_ARGS_04,
675 class t_ARGS_05>
676 t_TYPE& emplace(bslma::Allocator *allocator,
677 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
678 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
679 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
680 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
681 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
682#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 5
683
684#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 6
685 template <class t_ARGS_01,
686 class t_ARGS_02,
687 class t_ARGS_03,
688 class t_ARGS_04,
689 class t_ARGS_05,
690 class t_ARGS_06>
691 t_TYPE& emplace(bslma::Allocator *allocator,
692 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
693 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
694 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
695 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
696 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
697 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
698#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 6
699
700#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 7
701 template <class t_ARGS_01,
702 class t_ARGS_02,
703 class t_ARGS_03,
704 class t_ARGS_04,
705 class t_ARGS_05,
706 class t_ARGS_06,
707 class t_ARGS_07>
708 t_TYPE& emplace(bslma::Allocator *allocator,
709 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
710 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
711 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
712 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
713 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
714 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
715 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
716#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 7
717
718#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 8
719 template <class t_ARGS_01,
720 class t_ARGS_02,
721 class t_ARGS_03,
722 class t_ARGS_04,
723 class t_ARGS_05,
724 class t_ARGS_06,
725 class t_ARGS_07,
726 class t_ARGS_08>
727 t_TYPE& emplace(bslma::Allocator *allocator,
728 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
729 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
730 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
731 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
732 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
733 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
734 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
735 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
736#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 8
737
738#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 9
739 template <class t_ARGS_01,
740 class t_ARGS_02,
741 class t_ARGS_03,
742 class t_ARGS_04,
743 class t_ARGS_05,
744 class t_ARGS_06,
745 class t_ARGS_07,
746 class t_ARGS_08,
747 class t_ARGS_09>
748 t_TYPE& emplace(bslma::Allocator *allocator,
749 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
750 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
751 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
752 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
753 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
754 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
755 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
756 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
757 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
758#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 9
759
760#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 10
761 template <class t_ARGS_01,
762 class t_ARGS_02,
763 class t_ARGS_03,
764 class t_ARGS_04,
765 class t_ARGS_05,
766 class t_ARGS_06,
767 class t_ARGS_07,
768 class t_ARGS_08,
769 class t_ARGS_09,
770 class t_ARGS_10>
771 t_TYPE& emplace(bslma::Allocator *allocator,
772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
773 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
774 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
775 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
776 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
777 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
778 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
779 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
780 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
781 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
782#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 10
783
784
785# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
786#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 0
787 template <class t_INIT_LIST_TYPE>
788 t_TYPE& emplace(
789 bslma::Allocator *allocator,
790 std::initializer_list<t_INIT_LIST_TYPE> initializer_list);
791#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 0
792
793#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 1
794 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
795 t_TYPE& emplace(
796 bslma::Allocator *allocator,
797 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
798 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
799#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 1
800
801#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 2
802 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
803 class t_ARGS_02>
804 t_TYPE& emplace(
805 bslma::Allocator *allocator,
806 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
807 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
808 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
809#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 2
810
811#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 3
812 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
813 class t_ARGS_02,
814 class t_ARGS_03>
815 t_TYPE& emplace(
816 bslma::Allocator *allocator,
817 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
820 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
821#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 3
822
823#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 4
824 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
825 class t_ARGS_02,
826 class t_ARGS_03,
827 class t_ARGS_04>
828 t_TYPE& emplace(
829 bslma::Allocator *allocator,
830 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
831 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
832 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
833 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
834 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
835#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 4
836
837#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 5
838 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
839 class t_ARGS_02,
840 class t_ARGS_03,
841 class t_ARGS_04,
842 class t_ARGS_05>
843 t_TYPE& emplace(
844 bslma::Allocator *allocator,
845 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
846 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
847 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
848 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
849 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
850 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
851#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 5
852
853#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 6
854 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
855 class t_ARGS_02,
856 class t_ARGS_03,
857 class t_ARGS_04,
858 class t_ARGS_05,
859 class t_ARGS_06>
860 t_TYPE& emplace(
861 bslma::Allocator *allocator,
862 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
863 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
864 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
865 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
866 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
867 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
868 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
869#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 6
870
871#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 7
872 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
873 class t_ARGS_02,
874 class t_ARGS_03,
875 class t_ARGS_04,
876 class t_ARGS_05,
877 class t_ARGS_06,
878 class t_ARGS_07>
879 t_TYPE& emplace(
880 bslma::Allocator *allocator,
881 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
882 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
883 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
884 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
885 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
886 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
887 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
888 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
889#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 7
890
891#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 8
892 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
893 class t_ARGS_02,
894 class t_ARGS_03,
895 class t_ARGS_04,
896 class t_ARGS_05,
897 class t_ARGS_06,
898 class t_ARGS_07,
899 class t_ARGS_08>
900 t_TYPE& emplace(
901 bslma::Allocator *allocator,
902 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
903 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
904 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
905 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
906 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
907 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
908 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
909 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
910 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
911#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 8
912
913#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 9
914 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
915 class t_ARGS_02,
916 class t_ARGS_03,
917 class t_ARGS_04,
918 class t_ARGS_05,
919 class t_ARGS_06,
920 class t_ARGS_07,
921 class t_ARGS_08,
922 class t_ARGS_09>
923 t_TYPE& emplace(
924 bslma::Allocator *allocator,
925 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
926 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
927 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
928 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
929 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
930 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
931 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
932 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
933 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
934 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
935#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 9
936
937#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 10
938 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
939 class t_ARGS_02,
940 class t_ARGS_03,
941 class t_ARGS_04,
942 class t_ARGS_05,
943 class t_ARGS_06,
944 class t_ARGS_07,
945 class t_ARGS_08,
946 class t_ARGS_09,
947 class t_ARGS_10>
948 t_TYPE& emplace(
949 bslma::Allocator *allocator,
950 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
951 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
952 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
953 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
954 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
955 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
956 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
957 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
958 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
959 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
960 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
961#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_A >= 10
962
963# endif
964#else
965// The generated code below is a workaround for the absence of perfect
966// forwarding in some compilers.
967 template <class... t_ARGS>
968 t_TYPE& emplace(bslma::Allocator *allocator,
969 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
970
971# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
972 template <class t_INIT_LIST_TYPE, class... t_ARGS>
973 t_TYPE& emplace(
974 bslma::Allocator *allocator,
975 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
976 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
977# endif
978// }}} END GENERATED CODE
979#endif
980
981 /// Destroy the `value_type` object in `d_buffer`, if any.
983
984# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
985 /// Return the `value_type` object in `d_buffer` with const
986 /// qualification adjusted to match that of `t_TYPE`.
987 ///
988 /// \pre The behavior is undefined unless `this->hasValue() == true`.
989 t_TYPE& value() &;
990 t_TYPE&& value() &&;
991# else
992 /// Return the `value_type` object in `d_buffer` with const
993 /// qualification adjusted to match that of `t_TYPE`.
994 ///
995 /// \pre The behavior is undefined unless `this->hasValue() == true`.
996 t_TYPE& value();
997# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
998
999 // ACCESSORS
1000
1001 /// Return `true` if this objects has a value, and `false` otherwise.
1002 bool hasValue() const BSLS_KEYWORD_NOEXCEPT;
1003
1004# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1005 /// Return the `value_type` object in `d_buffer` with const
1006 /// qualification adjusted to match that of `t_TYPE`.
1007 ///
1008 /// \pre The behavior is undefined unless `this->hasValue() == true`.
1009 const t_TYPE& value() const &;
1010 const t_TYPE&& value() const &&;
1011
1012# else
1013 /// Return the `value_type` object in `d_buffer` with const qualification adjusted to match that of `t_TYPE`.
1014 ///
1015 /// \pre The behavior is undefined unless
1016 /// `this->hasValue() == true`.
1017 const t_TYPE& value() const;
1018# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
1019};
1020
1021 // ===================
1022 // class Optional_Data
1023 // ===================
1024
1025/// This component-private `struct` manages a `value_type` object in
1026/// `Optional_Base` by inheriting from `Optional_DataImp`. In addition,
1027/// this primary template properly destroys the owned instance of `t_TYPE`
1028/// in its destructor.
1029///
1030/// See @ref bslstl_optional_cpp03
1031template <
1032 class t_TYPE,
1033 bool t_IS_TRIVIALLY_DESTRUCTIBLE =
1035struct Optional_Data : public Optional_DataImp<t_TYPE> {
1036
1037 public:
1038 // CREATORS
1039#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1041#endif
1042
1043 /// Destroy the managed `value_type` object, if it exists.
1045};
1046
1047 // ===================
1048 // class Optional_Data
1049 // ===================
1050
1051/// This partial specialization manages a trivially destructible
1052/// `value_type` in Optional_Base. It does not have a user-provided
1053/// destructor, which makes it `is_trivially_destructible` itself.
1054template <class t_TYPE>
1055struct Optional_Data<t_TYPE, true> : public Optional_DataImp<t_TYPE> {
1056
1057 public:
1061
1062#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1063 // CREATORS
1065#endif
1066};
1067
1068 // ==========================
1069 // Component-private concepts
1070 // ==========================
1071
1072#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
1073template <class t_TYPE>
1074void optional_acceptsBslOptional(const bsl::optional<t_TYPE>&);
1075
1076template <class t_TYPE>
1077void optional_acceptsStdOptional(const std::optional<t_TYPE>&);
1078
1079// This component-private concept models the Standard's exposition-only
1080// `boolean-testable` concept.
1081template <class t_TYPE>
1082concept Optional_ConvertibleToBool =
1083 bsl::is_convertible_v<t_TYPE, bool>;
1084
1085// This component-private concept is used in the subsequent implementation
1086// of the component-private concept `Optional_DerivedFromOptional`.
1087template <class t_TYPE>
1088concept Optional_DerivedFromBslOptional =
1089 requires (const t_TYPE& t) { optional_acceptsBslOptional(t); };
1090
1091// This component-private concept is used in the subsequent implementation
1092// of the component-private concept `Optional_DerivedFromOptional`.
1093template <class t_TYPE>
1094concept Optional_DerivedFromStdOptional =
1095 requires (const t_TYPE& t) { optional_acceptsStdOptional(t); };
1096
1097/// This component-private concept models whether a type is derived from one
1098/// of `std::optional` or `bsl::optional`.
1099template <class t_TYPE>
1100concept Optional_DerivedFromOptional =
1101 Optional_DerivedFromBslOptional<t_TYPE> ||
1102 Optional_DerivedFromStdOptional<t_TYPE>;
1103#endif
1104
1105// ============================================================================
1106// Section: Definition of Allocator-Aware 'Optional_Base'
1107// ============================================================================
1108
1109 // ===================
1110 // class Optional_Base
1111 // ===================
1112
1113/// This component-private class template implements the functionality of
1114/// `bsl::optional`. The primary template is instantiated when `TYPE` is
1115/// allocator-aware, and holds the allocator that is used to create the
1116/// stored object.
1117///
1118/// See @ref bslstl_optional_cpp03
1119template <class t_TYPE,
1120 bool t_USES_BSLMA_ALLOC =
1121 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>
1122class Optional_Base {
1123
1124 public:
1125 // TYPES
1126
1127 /// `value_type` is an alias for the underlying `TYPE` upon which this
1128 /// template class is instantiated, and represents the type of the
1129 /// managed object. The name is chosen so it is compatible with the
1130 /// `std::optional` implementation.
1131 typedef t_TYPE value_type;
1132
1134
1135 protected:
1136 // PROTECTED TYPES
1137 typedef allocator_type AllocType;
1138
1139 private:
1140 // PRIVATE TYPES
1141 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
1142
1143# ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1144 // UNSPECIFIED BOOL
1145
1146 /// This type is needed only in C++03 mode, where `explicit` conversion
1147 /// operators are not supported. An `optional` object is contextually
1148 /// converted to `UnspecifiedBool` when used in `if` statements, but is not
1149 /// implicitly convertible to `bool`.
1150 typedef BloombergLP::bsls::UnspecifiedBool<Optional_Base>
1151 UnspecifiedBoolUtil;
1152 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
1153# endif
1154
1155 // DATA
1156
1157 // in-place `TYPE` object
1158 BloombergLP::bslstl::Optional_Data<t_TYPE> d_value;
1159
1160 // allocator to be used for all in-place `TYPE` objects
1161 allocator_type d_allocator;
1162
1163 protected:
1164 // PROTECTED CREATORS
1165
1166 /// Create a disengaged `Optional_Base` object. Use the currently
1167 /// installed default allocator to supply memory.
1168 Optional_Base();
1169
1170 /// Create a disengaged `Optional_Base` object. Use the currently
1171 /// installed default allocator to supply memory.
1172 Optional_Base(bsl::nullopt_t); // IMPLICIT
1173
1174 /// Create an `Optional_Base` object having the value of the specified
1175 /// `original` object. Use the currently installed default allocator to
1176 /// supply memory.
1177 Optional_Base(const Optional_Base& original);
1178
1179 /// Create an `Optional_Base` object having the same value as the
1180 /// specified `original` object by moving the contents of `original` to
1181 /// the newly-created object. The allocator associated with `original`
1182 /// is propagated for use in the newly-created object. `original` is
1183 /// left in a valid, but unspecified state.
1184 Optional_Base(BloombergLP::bslmf::MovableRef<Optional_Base> original)
1187
1188 /// Create an `Optional_Base` object whose contained value is
1189 /// initialized by forwarding from the specified `value`. Use the
1190 /// currently installed default allocator to supply memory.
1191 template <class t_ANY_TYPE>
1192 Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1194
1195 /// Create a disengaged `Optional_Base` object if the specified
1196 /// `original` object is disengaged, and an `Optional_Base` object with
1197 /// the value of `original.value()` converted to `t_TYPE` otherwise.
1198 /// Use the currently installed default allocator to supply memory.
1199 template <class t_ANY_TYPE>
1200 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1201 const Optional_Base<t_ANY_TYPE>& original);
1202
1203 /// Create a disengaged `Optional_Base` object if the specified
1204 /// `original` object is disengaged, and an `Optional_Base` object with
1205 /// the value of `original.value()` converted to `t_TYPE` otherwise.
1206 /// Use the currently installed default allocator to supply memory.
1207 /// `original` is left in a valid but unspecified state.
1208 template <class t_ANY_TYPE>
1210 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1211 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original,
1213 t_TYPE,
1214 t_ANY_TYPE));
1215
1216 /// Create a disengaged `Optional_Base` object if the specified
1217 /// `original` object is disengaged, and an `Optional_Base` object with
1218 /// the value of `original.value()` otherwise. This is a special case
1219 /// constructor where `t_ANY_TYPE` is a non-const version of `t_TYPE`
1220 /// and we use the allocator from `original` to supply memory.
1221 /// `original` is left in a valid but unspecified state.
1222 template <class t_ANY_TYPE>
1224 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1225 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original,
1227 t_ANY_TYPE));
1228
1229# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
1230 /// Create a disengaged `Optional_Base` object if the specified
1231 /// `original` object is disengaged, and an `Optional_Base` object with
1232 /// the value of `original.value()` converted to `t_TYPE` otherwise.
1233 /// Use the currently installed default allocator to supply memory.
1234 template <class t_ANY_TYPE>
1235 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1236 const std::optional<t_ANY_TYPE>& original);
1237
1238 /// Create a disengaged `Optional_Base` object if the specified
1239 /// `original` object is disengaged, and an `Optional_Base` object with
1240 /// the value of `original.value()` converted to `t_TYPE` otherwise.
1241 /// Use the currently installed default allocator to supply memory.
1242 template <class t_ANY_TYPE>
1243 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1244 std::optional<t_ANY_TYPE>&& original);
1245# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
1246
1247#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1248// {{{ BEGIN GENERATED CODE
1249// Command line: sim_cpp11_features.pl bslstl_optional.h
1250#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
1251#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
1252#endif
1253#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_B
1254#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_B BSLSTL_OPTIONAL_VARIADIC_LIMIT
1255#endif
1256#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 0
1258#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 0
1259
1260#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 1
1261 template <class t_ARGS_01>
1263 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
1264#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 1
1265
1266#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 2
1267 template <class t_ARGS_01,
1268 class t_ARGS_02>
1270 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1271 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
1272#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 2
1273
1274#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 3
1275 template <class t_ARGS_01,
1276 class t_ARGS_02,
1277 class t_ARGS_03>
1279 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1280 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
1282#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 3
1283
1284#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 4
1285 template <class t_ARGS_01,
1286 class t_ARGS_02,
1287 class t_ARGS_03,
1288 class t_ARGS_04>
1290 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1291 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1292 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1293 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
1294#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 4
1295
1296#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 5
1297 template <class t_ARGS_01,
1298 class t_ARGS_02,
1299 class t_ARGS_03,
1300 class t_ARGS_04,
1301 class t_ARGS_05>
1303 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1304 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1305 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1306 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
1308#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 5
1309
1310#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 6
1311 template <class t_ARGS_01,
1312 class t_ARGS_02,
1313 class t_ARGS_03,
1314 class t_ARGS_04,
1315 class t_ARGS_05,
1316 class t_ARGS_06>
1318 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1319 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1320 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1321 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1322 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1323 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
1324#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 6
1325
1326#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 7
1327 template <class t_ARGS_01,
1328 class t_ARGS_02,
1329 class t_ARGS_03,
1330 class t_ARGS_04,
1331 class t_ARGS_05,
1332 class t_ARGS_06,
1333 class t_ARGS_07>
1335 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1336 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1337 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1338 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1339 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1340 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1341 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
1342#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 7
1343
1344#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 8
1345 template <class t_ARGS_01,
1346 class t_ARGS_02,
1347 class t_ARGS_03,
1348 class t_ARGS_04,
1349 class t_ARGS_05,
1350 class t_ARGS_06,
1351 class t_ARGS_07,
1352 class t_ARGS_08>
1354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1357 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1358 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1359 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1360 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1361 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
1362#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 8
1363
1364#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 9
1365 template <class t_ARGS_01,
1366 class t_ARGS_02,
1367 class t_ARGS_03,
1368 class t_ARGS_04,
1369 class t_ARGS_05,
1370 class t_ARGS_06,
1371 class t_ARGS_07,
1372 class t_ARGS_08,
1373 class t_ARGS_09>
1375 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1376 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1377 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1378 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1379 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1380 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1381 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1382 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1383 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
1384#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 9
1385
1386#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 10
1387 template <class t_ARGS_01,
1388 class t_ARGS_02,
1389 class t_ARGS_03,
1390 class t_ARGS_04,
1391 class t_ARGS_05,
1392 class t_ARGS_06,
1393 class t_ARGS_07,
1394 class t_ARGS_08,
1395 class t_ARGS_09,
1396 class t_ARGS_10>
1398 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1399 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1400 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1401 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1402 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1403 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1404 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1405 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1406 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
1407 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
1408#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 10
1409
1410# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1411#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 0
1412 template <class t_INIT_LIST_TYPE>
1414 std::initializer_list<t_INIT_LIST_TYPE> il);
1415#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 0
1416
1417#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 1
1418 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
1420 std::initializer_list<t_INIT_LIST_TYPE> il,
1421 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
1422#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 1
1423
1424#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 2
1425 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1426 class t_ARGS_02>
1428 std::initializer_list<t_INIT_LIST_TYPE> il,
1429 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1430 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
1431#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 2
1432
1433#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 3
1434 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1435 class t_ARGS_02,
1436 class t_ARGS_03>
1438 std::initializer_list<t_INIT_LIST_TYPE> il,
1439 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1440 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1441 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
1442#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 3
1443
1444#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 4
1445 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1446 class t_ARGS_02,
1447 class t_ARGS_03,
1448 class t_ARGS_04>
1450 std::initializer_list<t_INIT_LIST_TYPE> il,
1451 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1452 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1453 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1454 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
1455#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 4
1456
1457#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 5
1458 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1459 class t_ARGS_02,
1460 class t_ARGS_03,
1461 class t_ARGS_04,
1462 class t_ARGS_05>
1464 std::initializer_list<t_INIT_LIST_TYPE> il,
1465 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1466 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1467 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1468 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1469 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
1470#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 5
1471
1472#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 6
1473 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1474 class t_ARGS_02,
1475 class t_ARGS_03,
1476 class t_ARGS_04,
1477 class t_ARGS_05,
1478 class t_ARGS_06>
1480 std::initializer_list<t_INIT_LIST_TYPE> il,
1481 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1482 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1483 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1484 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1485 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1486 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
1487#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 6
1488
1489#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 7
1490 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1491 class t_ARGS_02,
1492 class t_ARGS_03,
1493 class t_ARGS_04,
1494 class t_ARGS_05,
1495 class t_ARGS_06,
1496 class t_ARGS_07>
1498 std::initializer_list<t_INIT_LIST_TYPE> il,
1499 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1500 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1501 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1502 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1503 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1504 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1505 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
1506#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 7
1507
1508#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 8
1509 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1510 class t_ARGS_02,
1511 class t_ARGS_03,
1512 class t_ARGS_04,
1513 class t_ARGS_05,
1514 class t_ARGS_06,
1515 class t_ARGS_07,
1516 class t_ARGS_08>
1518 std::initializer_list<t_INIT_LIST_TYPE> il,
1519 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1520 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1521 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1522 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1523 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1524 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1525 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1526 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
1527#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 8
1528
1529#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 9
1530 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1531 class t_ARGS_02,
1532 class t_ARGS_03,
1533 class t_ARGS_04,
1534 class t_ARGS_05,
1535 class t_ARGS_06,
1536 class t_ARGS_07,
1537 class t_ARGS_08,
1538 class t_ARGS_09>
1540 std::initializer_list<t_INIT_LIST_TYPE> il,
1541 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1542 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1543 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1544 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1545 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1546 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1547 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1548 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1549 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
1550#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 9
1551
1552#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 10
1553 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1554 class t_ARGS_02,
1555 class t_ARGS_03,
1556 class t_ARGS_04,
1557 class t_ARGS_05,
1558 class t_ARGS_06,
1559 class t_ARGS_07,
1560 class t_ARGS_08,
1561 class t_ARGS_09,
1562 class t_ARGS_10>
1564 std::initializer_list<t_INIT_LIST_TYPE> il,
1565 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1566 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1567 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1568 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1569 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1570 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1571 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1572 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1573 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
1574 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
1575#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_B >= 10
1576
1577# endif
1578#else
1579// The generated code below is a workaround for the absence of perfect
1580// forwarding in some compilers.
1581 template <class... t_ARGS>
1583 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
1584# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1585 template <class t_INIT_LIST_TYPE, class... t_ARGS>
1587 std::initializer_list<t_INIT_LIST_TYPE> il,
1588 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
1589# endif
1590// }}} END GENERATED CODE
1591#endif
1592
1593#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1594 /// Create an `Optional_Base` object, which contains the result of
1595 /// invocation of the specified `invocable` with the specified `arg`.
1596 template <class t_INVOCABLE, class t_ARG>
1597 Optional_Base(Optional_InvokeConstructorTag ,
1598 t_INVOCABLE&& invocable,
1599 t_ARG&& arg);
1600#endif
1601
1602 // allocator-extended constructors
1603
1604 /// Create a disengaged `Optional_Base` object. Use the specified
1605 /// `allocator` to supply memory.
1607
1608 /// Create a disengaged `Optional_Base` object. Use the specified
1609 /// `allocator` to supply memory.
1611 allocator_type allocator,
1613
1614 /// If the specified `original` contains a value, create an
1615 /// `Optional_Base` object whose contained value is initialized from
1616 /// `*original`. Otherwise, create a disengaged `Optional_Base` object.
1617 /// Use the specified `allocator` to supply memory.
1619 allocator_type allocator,
1620 const Optional_Base& original);
1621
1622 /// If the specified `original` contains a value, create an
1623 /// `Optional_Base` object whose contained value is initialized by
1624 /// moving `*original`. Otherwise, create a disengaged `Optional_Base`
1625 /// object. Use the specified `allocator` to supply memory. `original`
1626 /// is left in a valid but unspecified state.
1628 allocator_type allocator,
1629 BloombergLP::bslmf::MovableRef<Optional_Base> original);
1630
1631 /// Create an `Optional_Base` object whose contained value is
1632 /// initialized by forwarding from the specified `value`. Use the
1633 /// specified `allocator` to supply memory.
1634 template <class t_ANY_TYPE>
1636 allocator_type allocator,
1637 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1639
1640 /// If the specified `original` contains a value, create an
1641 /// `Optional_Base` object whose contained value is initialized from
1642 /// `*original`, converted to `t_TYPE`. Otherwise, create a disengaged
1643 /// `Optional_Base`. Use the specified `allocator` to supply memory.
1644 template <class t_ANY_TYPE>
1646 allocator_type allocator,
1647 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1648 const Optional_Base<t_ANY_TYPE>& original);
1649
1650 /// If the specified `original` contains a value, create an
1651 /// `Optional_Base` object whose contained value is initialized by
1652 /// moving from `*original` and converting to `t_TYPE`. Otherwise,
1653 /// create a disengaged `Optional_Base`. Use the specified `allocator`
1654 /// to supply memory. `original` is left in a valid but unspecified
1655 /// state.
1656 template <class t_ANY_TYPE>
1658 allocator_type allocator,
1659 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1660 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original);
1661
1662# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
1663 /// If the specified `original` contains a value, create an
1664 /// `Optional_Base` object whose contained value is initialized from
1665 /// `*original`, converted to `t_TYPE`. Otherwise, create a disengaged
1666 /// `Optional_Base` object. Use the specified `allocator` to supply
1667 /// memory.
1668 template <class t_ANY_TYPE>
1670 allocator_type allocator,
1671 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1672 const std::optional<t_ANY_TYPE>& original);
1673
1674 /// If the specified `original` contains a value, create an
1675 /// `Optional_Base` object whose contained value is initialized from
1676 /// moving from `*original` and converting to `t_TYPE`. Otherwise,
1677 /// create a disengaged `Optional_Base`. Use the specified `allocator`
1678 /// to supply memory. `original` is left in a valid but unspecified
1679 /// state.
1680 template <class t_ANY_TYPE>
1682 allocator_type allocator,
1683 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1684 std::optional<t_ANY_TYPE>&& original);
1685# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
1686
1687#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1688// {{{ BEGIN GENERATED CODE
1689// Command line: sim_cpp11_features.pl bslstl_optional.h
1690#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
1691#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
1692#endif
1693#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_C
1694#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_C BSLSTL_OPTIONAL_VARIADIC_LIMIT
1695#endif
1696#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 0
1698 allocator_type allocator,
1700#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 0
1701
1702#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 1
1703 template <class t_ARGS_01>
1705 allocator_type allocator,
1707 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
1708#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 1
1709
1710#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 2
1711 template <class t_ARGS_01,
1712 class t_ARGS_02>
1714 allocator_type allocator,
1716 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1717 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
1718#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 2
1719
1720#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 3
1721 template <class t_ARGS_01,
1722 class t_ARGS_02,
1723 class t_ARGS_03>
1725 allocator_type allocator,
1727 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1728 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1729 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
1730#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 3
1731
1732#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 4
1733 template <class t_ARGS_01,
1734 class t_ARGS_02,
1735 class t_ARGS_03,
1736 class t_ARGS_04>
1738 allocator_type allocator,
1740 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1741 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1742 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1743 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
1744#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 4
1745
1746#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 5
1747 template <class t_ARGS_01,
1748 class t_ARGS_02,
1749 class t_ARGS_03,
1750 class t_ARGS_04,
1751 class t_ARGS_05>
1753 allocator_type allocator,
1755 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1756 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1757 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1758 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1759 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
1760#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 5
1761
1762#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 6
1763 template <class t_ARGS_01,
1764 class t_ARGS_02,
1765 class t_ARGS_03,
1766 class t_ARGS_04,
1767 class t_ARGS_05,
1768 class t_ARGS_06>
1770 allocator_type allocator,
1772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1773 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1774 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1775 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1776 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1777 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
1778#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 6
1779
1780#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 7
1781 template <class t_ARGS_01,
1782 class t_ARGS_02,
1783 class t_ARGS_03,
1784 class t_ARGS_04,
1785 class t_ARGS_05,
1786 class t_ARGS_06,
1787 class t_ARGS_07>
1789 allocator_type allocator,
1791 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1792 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1793 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1794 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1795 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1796 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1797 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
1798#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 7
1799
1800#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 8
1801 template <class t_ARGS_01,
1802 class t_ARGS_02,
1803 class t_ARGS_03,
1804 class t_ARGS_04,
1805 class t_ARGS_05,
1806 class t_ARGS_06,
1807 class t_ARGS_07,
1808 class t_ARGS_08>
1810 allocator_type allocator,
1812 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1813 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1814 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1815 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1816 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1817 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
1820#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 8
1821
1822#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 9
1823 template <class t_ARGS_01,
1824 class t_ARGS_02,
1825 class t_ARGS_03,
1826 class t_ARGS_04,
1827 class t_ARGS_05,
1828 class t_ARGS_06,
1829 class t_ARGS_07,
1830 class t_ARGS_08,
1831 class t_ARGS_09>
1833 allocator_type allocator,
1835 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1836 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1837 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1838 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1839 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1840 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1841 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1842 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1843 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
1844#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 9
1845
1846#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 10
1847 template <class t_ARGS_01,
1848 class t_ARGS_02,
1849 class t_ARGS_03,
1850 class t_ARGS_04,
1851 class t_ARGS_05,
1852 class t_ARGS_06,
1853 class t_ARGS_07,
1854 class t_ARGS_08,
1855 class t_ARGS_09,
1856 class t_ARGS_10>
1858 allocator_type allocator,
1860 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1861 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1862 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1863 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1864 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1865 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1866 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
1867 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
1868 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
1869 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
1870#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 10
1871
1872
1873# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1874#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 0
1875 template <class t_INIT_LIST_TYPE>
1877 allocator_type allocator,
1879 std::initializer_list<t_INIT_LIST_TYPE> il);
1880#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 0
1881
1882#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 1
1883 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
1885 allocator_type allocator,
1887 std::initializer_list<t_INIT_LIST_TYPE> il,
1888 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
1889#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 1
1890
1891#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 2
1892 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1893 class t_ARGS_02>
1895 allocator_type allocator,
1897 std::initializer_list<t_INIT_LIST_TYPE> il,
1898 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1899 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
1900#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 2
1901
1902#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 3
1903 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1904 class t_ARGS_02,
1905 class t_ARGS_03>
1907 allocator_type allocator,
1909 std::initializer_list<t_INIT_LIST_TYPE> il,
1910 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1911 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1912 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
1913#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 3
1914
1915#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 4
1916 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1917 class t_ARGS_02,
1918 class t_ARGS_03,
1919 class t_ARGS_04>
1921 allocator_type allocator,
1923 std::initializer_list<t_INIT_LIST_TYPE> il,
1924 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1925 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1926 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1927 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
1928#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 4
1929
1930#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 5
1931 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1932 class t_ARGS_02,
1933 class t_ARGS_03,
1934 class t_ARGS_04,
1935 class t_ARGS_05>
1937 allocator_type allocator,
1939 std::initializer_list<t_INIT_LIST_TYPE> il,
1940 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1941 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1942 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1943 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
1945#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 5
1946
1947#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 6
1948 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1949 class t_ARGS_02,
1950 class t_ARGS_03,
1951 class t_ARGS_04,
1952 class t_ARGS_05,
1953 class t_ARGS_06>
1955 allocator_type allocator,
1957 std::initializer_list<t_INIT_LIST_TYPE> il,
1958 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1959 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1960 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1961 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1962 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1963 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
1964#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 6
1965
1966#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 7
1967 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1968 class t_ARGS_02,
1969 class t_ARGS_03,
1970 class t_ARGS_04,
1971 class t_ARGS_05,
1972 class t_ARGS_06,
1973 class t_ARGS_07>
1975 allocator_type allocator,
1977 std::initializer_list<t_INIT_LIST_TYPE> il,
1978 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
1979 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
1980 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
1981 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
1982 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
1983 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
1984 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
1985#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 7
1986
1987#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 8
1988 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
1989 class t_ARGS_02,
1990 class t_ARGS_03,
1991 class t_ARGS_04,
1992 class t_ARGS_05,
1993 class t_ARGS_06,
1994 class t_ARGS_07,
1995 class t_ARGS_08>
1997 allocator_type allocator,
1999 std::initializer_list<t_INIT_LIST_TYPE> il,
2000 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2001 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2002 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2003 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2004 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2005 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2006 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2007 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
2008#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 8
2009
2010#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 9
2011 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2012 class t_ARGS_02,
2013 class t_ARGS_03,
2014 class t_ARGS_04,
2015 class t_ARGS_05,
2016 class t_ARGS_06,
2017 class t_ARGS_07,
2018 class t_ARGS_08,
2019 class t_ARGS_09>
2021 allocator_type allocator,
2023 std::initializer_list<t_INIT_LIST_TYPE> il,
2024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2026 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2027 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2028 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2029 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2030 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2031 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2032 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
2033#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 9
2034
2035#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 10
2036 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2037 class t_ARGS_02,
2038 class t_ARGS_03,
2039 class t_ARGS_04,
2040 class t_ARGS_05,
2041 class t_ARGS_06,
2042 class t_ARGS_07,
2043 class t_ARGS_08,
2044 class t_ARGS_09,
2045 class t_ARGS_10>
2047 allocator_type allocator,
2049 std::initializer_list<t_INIT_LIST_TYPE> il,
2050 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2051 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2052 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2053 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2054 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2055 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2056 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2057 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2058 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
2059 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
2060#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_C >= 10
2061
2062# endif
2063#else
2064// The generated code below is a workaround for the absence of perfect
2065// forwarding in some compilers.
2066 template <class... t_ARGS>
2068 allocator_type allocator,
2070 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
2071
2072# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2073 template <class t_INIT_LIST_TYPE, class... t_ARGS>
2075 allocator_type allocator,
2077 std::initializer_list<t_INIT_LIST_TYPE> il,
2078 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
2079# endif
2080// }}} END GENERATED CODE
2081#endif
2082
2083 // PROTECTED MANIPULATORS
2084
2085 /// If `*this` holds an object, assign to that object the value of the
2086 /// specified `rhs`, converted to `t_TYPE`. Otherwise, construct a held
2087 /// object from `rhs`, converted to `t_TYPE`. The allocators of `*this`
2088 /// and `rhs` remain unchanged.
2089 template <class t_ANY_TYPE>
2091
2092# ifndef BDE_OMIT_INTERNAL_DEPRECATED
2093 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
2094 ///
2095 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
2096 ///
2097 /// \note Note that this function is only intended to
2098 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use 'bsl::Optional_Base.
2099 ///
2100 /// \note Note that ref-qualified
2101 /// versions of `value()` are not provided because `NullableValue` does
2102 /// not require them.
2103 t_TYPE& dereferenceRaw();
2104
2105 // PROTECTED ACCESSORS
2106
2107 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
2108 ///
2109 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
2110 ///
2111 /// \note Note that this function is only intended to
2112 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use 'bsl::Optional_Base.
2113 ///
2114 /// \note Note that ref-qualified
2115 /// versions of `value()` are not provided because `NullableValue` does
2116 /// not require them.
2117 const t_TYPE& dereferenceRaw() const;
2118# endif // BDE_OMIT_INTERNAL_DEPRECATED
2119
2120 public:
2121 // TRAITS
2123 BloombergLP::bslma::UsesBslmaAllocator);
2125 BloombergLP::bslmf::UsesAllocatorArgT);
2128 BloombergLP::bslmf::IsBitwiseMoveable,
2129 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
2132 BloombergLP::bslmf::IsBitwiseCopyable,
2133 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
2134
2135 // MANIPULATORS
2136
2137#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2138// {{{ BEGIN GENERATED CODE
2139// Command line: sim_cpp11_features.pl bslstl_optional.h
2140#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
2141#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
2142#endif
2143#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_D
2144#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_D BSLSTL_OPTIONAL_VARIADIC_LIMIT
2145#endif
2146#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 0
2147 t_TYPE& emplace();
2148#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 0
2149
2150#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 1
2151 template <class t_ARGS_01>
2152 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
2153#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 1
2154
2155#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 2
2156 template <class t_ARGS_01,
2157 class t_ARGS_02>
2158 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2159 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
2160#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 2
2161
2162#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 3
2163 template <class t_ARGS_01,
2164 class t_ARGS_02,
2165 class t_ARGS_03>
2166 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2167 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2168 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
2169#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 3
2170
2171#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 4
2172 template <class t_ARGS_01,
2173 class t_ARGS_02,
2174 class t_ARGS_03,
2175 class t_ARGS_04>
2176 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2177 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2178 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2179 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
2180#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 4
2181
2182#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 5
2183 template <class t_ARGS_01,
2184 class t_ARGS_02,
2185 class t_ARGS_03,
2186 class t_ARGS_04,
2187 class t_ARGS_05>
2188 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2189 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2190 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2191 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2192 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
2193#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 5
2194
2195#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 6
2196 template <class t_ARGS_01,
2197 class t_ARGS_02,
2198 class t_ARGS_03,
2199 class t_ARGS_04,
2200 class t_ARGS_05,
2201 class t_ARGS_06>
2202 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2203 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2204 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2205 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2206 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2207 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
2208#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 6
2209
2210#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 7
2211 template <class t_ARGS_01,
2212 class t_ARGS_02,
2213 class t_ARGS_03,
2214 class t_ARGS_04,
2215 class t_ARGS_05,
2216 class t_ARGS_06,
2217 class t_ARGS_07>
2218 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2219 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2220 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2221 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2222 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2223 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2224 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
2225#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 7
2226
2227#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 8
2228 template <class t_ARGS_01,
2229 class t_ARGS_02,
2230 class t_ARGS_03,
2231 class t_ARGS_04,
2232 class t_ARGS_05,
2233 class t_ARGS_06,
2234 class t_ARGS_07,
2235 class t_ARGS_08>
2236 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2237 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2238 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2239 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2241 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2242 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2243 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
2244#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 8
2245
2246#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 9
2247 template <class t_ARGS_01,
2248 class t_ARGS_02,
2249 class t_ARGS_03,
2250 class t_ARGS_04,
2251 class t_ARGS_05,
2252 class t_ARGS_06,
2253 class t_ARGS_07,
2254 class t_ARGS_08,
2255 class t_ARGS_09>
2256 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2257 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2258 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2259 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2260 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2261 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2262 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2263 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
2265#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 9
2266
2267#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 10
2268 template <class t_ARGS_01,
2269 class t_ARGS_02,
2270 class t_ARGS_03,
2271 class t_ARGS_04,
2272 class t_ARGS_05,
2273 class t_ARGS_06,
2274 class t_ARGS_07,
2275 class t_ARGS_08,
2276 class t_ARGS_09,
2277 class t_ARGS_10>
2278 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2279 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2280 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2282 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2283 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2284 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2285 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2286 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
2287 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
2288#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 10
2289
2290
2291# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2292#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 0
2293 template <class t_INIT_LIST_TYPE>
2294 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il);
2295#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 0
2296
2297#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 1
2298 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
2299 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2300 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
2301#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 1
2302
2303#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 2
2304 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2305 class t_ARGS_02>
2306 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2308 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
2309#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 2
2310
2311#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 3
2312 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2313 class t_ARGS_02,
2314 class t_ARGS_03>
2315 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2316 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2317 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2318 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
2319#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 3
2320
2321#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 4
2322 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2323 class t_ARGS_02,
2324 class t_ARGS_03,
2325 class t_ARGS_04>
2326 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2327 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2328 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2329 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2330 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
2331#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 4
2332
2333#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 5
2334 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2335 class t_ARGS_02,
2336 class t_ARGS_03,
2337 class t_ARGS_04,
2338 class t_ARGS_05>
2339 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2340 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2341 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2342 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2343 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2344 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
2345#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 5
2346
2347#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 6
2348 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2349 class t_ARGS_02,
2350 class t_ARGS_03,
2351 class t_ARGS_04,
2352 class t_ARGS_05,
2353 class t_ARGS_06>
2354 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2357 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2358 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2359 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2360 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
2361#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 6
2362
2363#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 7
2364 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2365 class t_ARGS_02,
2366 class t_ARGS_03,
2367 class t_ARGS_04,
2368 class t_ARGS_05,
2369 class t_ARGS_06,
2370 class t_ARGS_07>
2371 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2372 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2373 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2374 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2375 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2376 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2377 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2378 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
2379#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 7
2380
2381#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 8
2382 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2383 class t_ARGS_02,
2384 class t_ARGS_03,
2385 class t_ARGS_04,
2386 class t_ARGS_05,
2387 class t_ARGS_06,
2388 class t_ARGS_07,
2389 class t_ARGS_08>
2390 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2391 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2392 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2393 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2394 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2395 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2396 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2397 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2398 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
2399#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 8
2400
2401#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 9
2402 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2403 class t_ARGS_02,
2404 class t_ARGS_03,
2405 class t_ARGS_04,
2406 class t_ARGS_05,
2407 class t_ARGS_06,
2408 class t_ARGS_07,
2409 class t_ARGS_08,
2410 class t_ARGS_09>
2411 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2412 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2413 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2414 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2415 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2416 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2417 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2418 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2419 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2420 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
2421#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 9
2422
2423#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 10
2424 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
2425 class t_ARGS_02,
2426 class t_ARGS_03,
2427 class t_ARGS_04,
2428 class t_ARGS_05,
2429 class t_ARGS_06,
2430 class t_ARGS_07,
2431 class t_ARGS_08,
2432 class t_ARGS_09,
2433 class t_ARGS_10>
2434 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2435 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2436 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2437 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2438 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2439 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2440 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
2441 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
2442 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
2443 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
2444 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
2445#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_D >= 10
2446
2447
2448# endif
2449#else
2450// The generated code below is a workaround for the absence of perfect
2451// forwarding in some compilers.
2452 template <class... t_ARGS>
2453 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
2454
2455# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2456 template <class t_INIT_LIST_TYPE, class... t_ARGS>
2457 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
2458 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
2459
2460# endif
2461// }}} END GENERATED CODE
2462#endif
2463 /// Reset this object to the default constructed state (i.e., to a
2464 /// disengaged state).
2466
2467 /// Efficiently exchange the value of this object with the value of the
2468 /// specified `other` object. This method provides the no-throw
2469 /// exception-safety guarantee if the template parameter `t_TYPE` provides
2470 /// that guarantee and the result of the `hasValue` method for the two objects being swapped is the same.
2471 ///
2472 /// \pre The behavior is undefined unless
2473 /// this object was created with the same allocator as `other`.
2475 bsl::is_nothrow_move_constructible<t_TYPE>::value &&
2476 bsl::is_nothrow_swappable<t_TYPE>::value);
2477
2478# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2479 /// Return a reference providing modifiable access to the underlying
2480 /// `t_TYPE` object if `true == has_value()` and throw
2481 /// `bsl::bad_optional_access` otherwise.
2482 t_TYPE& value() &;
2483 t_TYPE&& value() &&;
2484# else
2485 /// Return a reference providing modifiable access to the underlying
2486 /// `t_TYPE` object. Throws a `bsl::bad_optional_access` if the
2487 /// `Optional_Base` object is disengaged.
2488 t_TYPE& value();
2489# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
2490
2491# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2492 /// Return a copy of the underlying object of a (template parameter)
2493 /// `t_TYPE` if this object is non-null, and the specified `value` converted to `t_TYPE` otherwise.
2494 ///
2495 /// \note Note that this method returns *by*
2496 /// *value*, so may be inefficient in some contexts.
2497 template <class t_ANY_TYPE>
2498 t_TYPE value_or(t_ANY_TYPE&& value) &&;
2499# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2500 /// If this object is non-null, return a copy of the underlying object
2501 /// of a (template parameter) `t_TYPE` created using the provided
2502 /// allocator, and the specified `value` converted to `t_TYPE` using the specified `allocator` otherwise.
2503 ///
2504 /// \note Note that this method returns *by*
2505 /// *value*, so may be inefficient in some contexts.
2506 template <class t_ANY_TYPE>
2509 t_ANY_TYPE&& value) &&;
2510# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2511# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2512
2513 /// Assign to this object the value of the specified `rhs` object, and
2514 /// return a non-`const` reference to this object.
2516
2517 /// Assign to this object the value of the specified `rhs` object, and
2518 /// return a non-`const` reference to this object. The allocators of this
2519 /// object and `rhs` both remain unchanged. The contents of `rhs` are
2520 /// either move-constructed into or move-assigned to this object. `rhs` is
2521 /// left in a valid but unspecified state.
2523 BloombergLP::bslmf::MovableRef<Optional_Base> rhs);
2524
2525 /// Return a pointer providing modifiable access to the underlying `t_TYPE` object.
2526 ///
2527 /// \pre The behavior is undefined if the `Optional_Base` object is
2528 /// disengaged.
2529 t_TYPE *operator->();
2530
2531# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2532 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
2533 ///
2534 /// \pre The behavior is undefined if the `Optional_Base`
2535 /// object is disengaged.
2536 t_TYPE& operator*() &;
2537 t_TYPE&& operator*() &&;
2538# else
2539 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
2540 ///
2541 /// \pre The behavior is undefined if the `Optional_Base`
2542 /// object is disengaged.
2543 t_TYPE& operator*();
2544# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
2545
2546 // ACCESSORS
2547
2548 /// Return allocator used for construction of `value_type`.
2550
2551 /// Return `false` if this object is disengaged, and `true` otherwise.
2552 bool has_value() const BSLS_KEYWORD_NOEXCEPT;
2553
2554# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2555 /// Return a reference providing non-modifiable access to the underlying
2556 /// `t_TYPE` object if `true == has_value()` and throw
2557 /// `bsl::bad_optional_access` otherwise.
2558 const t_TYPE& value() const &;
2559 const t_TYPE&& value() const &&;
2560# else
2561 /// Return a reference providing non-modifiable access to the underlying
2562 /// `t_TYPE` object. Throws a `bsl::bad_optional_access` if the
2563 /// `Optional_Base` object is disengaged.
2564 const t_TYPE& value() const;
2565# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
2566
2567 /// Return a pointer providing non-modifiable access to the underlying `t_TYPE` object.
2568 ///
2569 /// \pre The behavior is undefined if the `Optional_Base`
2570 /// object is disengaged.
2571 const t_TYPE *operator->() const;
2572
2573# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2574 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
2575 ///
2576 /// \pre The behavior is undefined if the `Optional_Base`
2577 /// object is disengaged.
2578 const t_TYPE& operator*() const &;
2579 const t_TYPE&& operator*() const &&;
2580# else
2581 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
2582 ///
2583 /// \pre The behavior is undefined if the `Optional_Base`
2584 /// object is disengaged.
2585 const t_TYPE& operator*() const;
2586# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
2587
2588# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2589 /// Return a copy of the underlying object of a (template parameter)
2590 /// `t_TYPE` if this object is non-null, and the specified `value` converted to `t_TYPE` otherwise.
2591 ///
2592 /// \note Note that this method returns *by*
2593 /// *value*, so may be inefficient in some contexts.
2594 template <class t_ANY_TYPE>
2595 t_TYPE value_or(
2596 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const&;
2597# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2598 /// If this object is non-null, return a copy of the underlying object
2599 /// of a (template parameter) `t_TYPE` created using the provided
2600 /// allocator, and the specified `value` converted to `t_TYPE` using the specified `allocator` otherwise.
2601 ///
2602 /// \note Note that this method returns *by*
2603 /// *value*, so may be inefficient in some contexts.
2604 template <class t_ANY_TYPE>
2605 t_TYPE value_or(
2608 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const&;
2609# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2610# else
2611 /// Return a copy of the underlying object of a (template parameter)
2612 /// `t_TYPE` if this object is non-null, and the specified `value` converted to `t_TYPE` otherwise.
2613 ///
2614 /// \note Note that this method returns **by
2615 /// value**, so may be inefficient in some contexts.
2616 template <class t_ANY_TYPE>
2617 t_TYPE value_or(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const;
2618# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2619 /// If this object is non-null, return a copy of the underlying object of a
2620 /// (template parameter) `t_TYPE` created using the provided allocator, and
2621 /// the specified `value` converted to `t_TYPE` using the specified `allocator` otherwise.
2622 ///
2623 /// \note Note that this method returns **by value**, so
2624 /// may be inefficient in some contexts.
2625 template <class t_ANY_TYPE>
2628 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const;
2629# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
2630# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
2631
2632#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
2633 /// Return `false` if this object is disengaged, and `true` otherwise.
2634 explicit operator bool() const BSLS_KEYWORD_NOEXCEPT;
2635#else
2636 /// Simulation of explicit conversion to bool. Inlined to work around xlC
2637 /// bug when out-of-line.
2638 operator UnspecifiedBool() const BSLS_NOTHROW_SPEC
2639 {
2640 return UnspecifiedBoolUtil::makeValue(has_value());
2641 }
2642#endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT else
2643};
2644
2645// ============================================================================
2646// Section: Definition of C++17 Allocator-Unaware 'Optional_Base'
2647// ============================================================================
2648
2649 // ==================================
2650 // class Optional_Base<t_TYPE, false>
2651 // ==================================
2652
2653# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
2654/// Specialization of `Optional_Base` for `value_type` that is not
2655/// allocator-aware when `std::optional` is available.
2656template <class t_TYPE>
2657class Optional_Base<t_TYPE, false> : public std::optional<t_TYPE> {
2658
2659 private:
2660 // PRIVATE TYPES
2661 typedef std::optional<t_TYPE> StdOptionalBase;
2662
2663 protected:
2664 // PROTECTED TYPES
2665 struct AllocType {
2666 private:
2667 // NOT IMPLEMENTED
2668
2669 /// This constructor prevents `AllocType` from being an aggregate.
2670 explicit AllocType(int) = delete;
2671 };
2672
2673 // PROTECTED CREATORS
2674
2675 /// Create a disengaged `Optional_Base` object.
2676 constexpr Optional_Base();
2677
2678 /// Create a disengaged `Optional_Base` object.
2679 constexpr Optional_Base(bsl::nullopt_t); // IMPLICIT
2680
2681 /// Create an `Optional_Base` object whose contained value is initialized
2682 /// by forwarding from the specified `value`.
2683 template <class t_ANY_TYPE>
2684 constexpr
2685 Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef,
2686 t_ANY_TYPE&& value);
2687
2688 /// Create a disengaged `Optional_Base` object if the specified `original`
2689 /// object is disengaged, and an `Optional_Base` object with the value of
2690 /// `original.value()` (of `t_ANY_TYPE`) converted to `t_TYPE` otherwise.
2691 template <class t_ANY_TYPE>
2693 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
2694 const Optional_Base<t_ANY_TYPE>& original);
2695
2696 /// Create a disengaged `Optional_Base` object if the specified `original`
2697 /// object is disengaged, and an `Optional_Base` object with the value of
2698 /// `original.value()` (of `t_ANY_TYPE`) converted to `t_TYPE` otherwise.
2699 /// `original` is left in a valid but unspecified state.
2700 template <class t_ANY_TYPE>
2702 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
2703 Optional_Base<t_ANY_TYPE>&& original);
2704
2705 template <class t_ANY_TYPE>
2707 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
2708 const std::optional<t_ANY_TYPE>& original);
2709
2710 template <class t_ANY_TYPE>
2712 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
2713 std::optional<t_ANY_TYPE>&& original);
2714
2715 /// Create an `Optional_Base` object whose contained value is initialized
2716 /// from the specified `args`.
2717 template <class... t_ARGS>
2718 explicit constexpr Optional_Base(bsl::in_place_t, t_ARGS&&... args);
2719
2720 /// Create an `Optional_Base` object whose contained value is initialized
2721 /// from the specified `il` and `args`.
2722 template <class t_INIT_LIST_TYPE, class... t_ARGS>
2723 constexpr
2725 std::initializer_list<t_INIT_LIST_TYPE> il,
2726 t_ARGS&&... args);
2727
2728#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
2729 /// Create an `Optional_Base` object, which contains the result of
2730 /// invocation of the specified `invocable` with the specified `arg`.
2731 template <class t_INVOCABLE, class t_ARG>
2732 Optional_Base(Optional_InvokeConstructorTag ,
2733 t_INVOCABLE&& invocable,
2734 t_ARG&& arg);
2735#endif
2736
2737 /// These allocator-extended constructors cannot be called, and are
2738 /// provided only to prevent compilation errors when 'optional' is
2739 /// explicitly instantiated.
2741
2743
2744 template <class t_ANY_TYPE>
2746 AllocType,
2747 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
2748 t_ANY_TYPE&&);
2749
2750 template <class t_ANY_TYPE>
2752 AllocType,
2753 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
2754 const Optional_Base<t_ANY_TYPE>&);
2755
2756 template <class t_ANY_TYPE>
2758 AllocType,
2759 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
2760 Optional_Base<t_ANY_TYPE>&&);
2761
2762 template <class t_ANY_TYPE>
2764 AllocType,
2765 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
2766 const std::optional<t_ANY_TYPE>&);
2767
2768 template <class t_ANY_TYPE>
2770 AllocType,
2771 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
2772 std::optional<t_ANY_TYPE>&&);
2773
2774 template <class... t_ARGS>
2776 AllocType,
2778 t_ARGS&&...);
2779
2780 template <class t_INIT_LIST_TYPE, class... t_ARGS>
2782 AllocType,
2784 std::initializer_list<t_INIT_LIST_TYPE>,
2785 t_ARGS&&...);
2786
2787 // PROTECTED MANIPULATORS
2788
2789 /// If `*this` holds an object, assign to that object the value of the
2790 /// specified `rhs`, converted to `t_TYPE`. Otherwise, construct a held
2791 /// object from `rhs`, converted to `t_TYPE`.
2792 template <class t_ANY_TYPE>
2793 BSLSTL_OPTIONAL_CONSTEXPR20 void assignOrEmplace(t_ANY_TYPE&& rhs);
2794
2795# ifndef BDE_OMIT_INTERNAL_DEPRECATED
2796 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
2797 ///
2798 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
2799 ///
2800 /// \note Note that this function is only intended to
2801 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use 'bsl::Optional_Base.
2802 ///
2803 /// \note Note that ref-qualified
2804 /// versions of `value()` are not provided because `NullableValue` does
2805 /// not require them.
2806 t_TYPE& dereferenceRaw();
2807
2808 // PROTECTED ACCESSORS
2809
2810 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
2811 ///
2812 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
2813 ///
2814 /// \note Note that this function is only intended to
2815 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use 'bsl::Optional_Base.
2816 ///
2817 /// \note Note that ref-qualified
2818 /// versions of `value()` are not provided because `NullableValue` does
2819 /// not require them.
2820 const t_TYPE& dereferenceRaw() const;
2821# endif // BDE_OMIT_INTERNAL_DEPRECATED
2822
2823 public:
2824 // TRAITS
2827 BloombergLP::bslmf::IsBitwiseMoveable,
2828 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
2831 BloombergLP::bslmf::IsBitwiseCopyable,
2832 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
2833};
2834# else // BSLSTL_OPTIONAL_USES_STD_ALIASES
2835
2836// ============================================================================
2837// Section: Definition of Pre-C++17 Allocator-Unaware 'Optional_Base'
2838// ============================================================================
2839
2840 // ==================================
2841 // class Optional_Base<t_TYPE, false>
2842 // ==================================
2843
2844/// Specialization of `Optional_Base` for `value_type` that is not
2845/// allocator-aware.
2846template <class t_TYPE>
2847class Optional_Base<t_TYPE, false> {
2848
2849 private:
2850 // PRIVATE TYPES
2851 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2852
2853# ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
2854 // UNSPECIFIED BOOL
2855
2856 /// This type is needed only in C++03 mode, where 'explicit' conversion
2857 /// operators are not supported. An 'optional' object is contextually
2858 /// converted to 'UnspecifiedBool' when used in 'if' statements, but is not
2859 /// implicitly convertible to 'bool'.
2860 typedef BloombergLP::bsls::UnspecifiedBool<Optional_Base>
2861 UnspecifiedBoolUtil;
2862 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
2863# endif
2864
2865 // DATA
2866
2867 /// in-place `TYPE` object
2868 BloombergLP::bslstl::Optional_Data<t_TYPE> d_value;
2869
2870 protected:
2871 // PROTECTED TYPES
2872 struct AllocType {
2873 private:
2874 // NOT IMPLEMENTED
2875
2876 /// This constructor prevents `AllocType` from being an aggregate.
2877 explicit AllocType(int) BSLS_KEYWORD_DELETED;
2878 };
2879
2880 // PROTECTED CREATORS
2881
2882 /// Create a disengaged `Optional_Base` object.
2883 Optional_Base();
2884
2885 /// Create a disengaged `Optional_Base` object.
2886 Optional_Base(bsl::nullopt_t); // IMPLICIT
2887
2888 /// Create an `Optional_Base` object having the value of the specified
2889 /// `original` object.
2890 Optional_Base(const Optional_Base& original);
2891
2892 /// Create an `Optional_Base` object having the same value as the
2893 /// specified `original` object by moving the contents of `original` to
2894 /// the newly-created object. `original` is left in a valid, but
2895 /// unspecified state.
2896 Optional_Base(BloombergLP::bslmf::MovableRef<Optional_Base> original)
2899
2900 /// Create an `Optional_Base` object whose contained value is initialized
2901 /// by forwarding from the specified `value`.
2902 template <class t_ANY_TYPE>
2903 Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef,
2905
2906 /// Create a disengaged `Optional_Base` object if the specified
2907 /// `original` object is disengaged, and an `Optional_Base` object with
2908 /// the value of `original.value()` converted to `t_TYPE` otherwise.
2909 template <class t_ANY_TYPE>
2910 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
2911 const Optional_Base<t_ANY_TYPE>& original);
2912
2913 /// Create a disengaged `Optional_Base` object if the specified
2914 /// `original` object is disengaged, and an `Optional_Base` object with
2915 /// the value of `original.value()` converted to `t_TYPE` otherwise.
2916 /// `original` is left in a valid but unspecified state.
2917 template <class t_ANY_TYPE>
2918 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
2919 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original);
2920
2921#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2922// {{{ BEGIN GENERATED CODE
2923// Command line: sim_cpp11_features.pl bslstl_optional.h
2924#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
2925#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
2926#endif
2927#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_E
2928#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_E BSLSTL_OPTIONAL_VARIADIC_LIMIT
2929#endif
2930#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 0
2932#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 0
2933
2934#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 1
2935 template <class t_ARGS_01>
2937 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
2938#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 1
2939
2940#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 2
2941 template <class t_ARGS_01,
2942 class t_ARGS_02>
2944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2945 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
2946#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 2
2947
2948#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 3
2949 template <class t_ARGS_01,
2950 class t_ARGS_02,
2951 class t_ARGS_03>
2953 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2954 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2955 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
2956#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 3
2957
2958#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 4
2959 template <class t_ARGS_01,
2960 class t_ARGS_02,
2961 class t_ARGS_03,
2962 class t_ARGS_04>
2964 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2965 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2966 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2967 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
2968#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 4
2969
2970#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 5
2971 template <class t_ARGS_01,
2972 class t_ARGS_02,
2973 class t_ARGS_03,
2974 class t_ARGS_04,
2975 class t_ARGS_05>
2977 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2978 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2979 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2980 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2981 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
2982#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 5
2983
2984#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 6
2985 template <class t_ARGS_01,
2986 class t_ARGS_02,
2987 class t_ARGS_03,
2988 class t_ARGS_04,
2989 class t_ARGS_05,
2990 class t_ARGS_06>
2992 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
2993 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
2994 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
2995 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
2996 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
2997 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
2998#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 6
2999
3000#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 7
3001 template <class t_ARGS_01,
3002 class t_ARGS_02,
3003 class t_ARGS_03,
3004 class t_ARGS_04,
3005 class t_ARGS_05,
3006 class t_ARGS_06,
3007 class t_ARGS_07>
3009 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3010 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3011 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3012 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3013 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3014 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3015 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
3016#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 7
3017
3018#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 8
3019 template <class t_ARGS_01,
3020 class t_ARGS_02,
3021 class t_ARGS_03,
3022 class t_ARGS_04,
3023 class t_ARGS_05,
3024 class t_ARGS_06,
3025 class t_ARGS_07,
3026 class t_ARGS_08>
3028 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3029 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3030 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3031 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3032 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3033 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3034 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3035 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
3036#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 8
3037
3038#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 9
3039 template <class t_ARGS_01,
3040 class t_ARGS_02,
3041 class t_ARGS_03,
3042 class t_ARGS_04,
3043 class t_ARGS_05,
3044 class t_ARGS_06,
3045 class t_ARGS_07,
3046 class t_ARGS_08,
3047 class t_ARGS_09>
3049 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3050 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3051 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3052 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3053 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3054 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3055 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3056 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3057 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
3058#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 9
3059
3060#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 10
3061 template <class t_ARGS_01,
3062 class t_ARGS_02,
3063 class t_ARGS_03,
3064 class t_ARGS_04,
3065 class t_ARGS_05,
3066 class t_ARGS_06,
3067 class t_ARGS_07,
3068 class t_ARGS_08,
3069 class t_ARGS_09,
3070 class t_ARGS_10>
3072 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3073 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3074 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3075 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3076 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3077 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3078 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3079 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3080 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
3081 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
3082#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 10
3083
3084
3085# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3086#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 0
3087 template <class t_INIT_LIST_TYPE>
3089 std::initializer_list<t_INIT_LIST_TYPE> il);
3090#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 0
3091
3092#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 1
3093 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
3095 std::initializer_list<t_INIT_LIST_TYPE> il,
3096 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
3097#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 1
3098
3099#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 2
3100 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3101 class t_ARGS_02>
3103 std::initializer_list<t_INIT_LIST_TYPE> il,
3104 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3105 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
3106#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 2
3107
3108#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 3
3109 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3110 class t_ARGS_02,
3111 class t_ARGS_03>
3113 std::initializer_list<t_INIT_LIST_TYPE> il,
3114 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3115 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3116 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
3117#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 3
3118
3119#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 4
3120 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3121 class t_ARGS_02,
3122 class t_ARGS_03,
3123 class t_ARGS_04>
3125 std::initializer_list<t_INIT_LIST_TYPE> il,
3126 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3127 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3128 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3129 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
3130#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 4
3131
3132#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 5
3133 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3134 class t_ARGS_02,
3135 class t_ARGS_03,
3136 class t_ARGS_04,
3137 class t_ARGS_05>
3139 std::initializer_list<t_INIT_LIST_TYPE> il,
3140 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3141 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3142 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3143 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3144 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
3145#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 5
3146
3147#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 6
3148 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3149 class t_ARGS_02,
3150 class t_ARGS_03,
3151 class t_ARGS_04,
3152 class t_ARGS_05,
3153 class t_ARGS_06>
3155 std::initializer_list<t_INIT_LIST_TYPE> il,
3156 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3157 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3158 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3159 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3160 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3161 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
3162#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 6
3163
3164#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 7
3165 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3166 class t_ARGS_02,
3167 class t_ARGS_03,
3168 class t_ARGS_04,
3169 class t_ARGS_05,
3170 class t_ARGS_06,
3171 class t_ARGS_07>
3173 std::initializer_list<t_INIT_LIST_TYPE> il,
3174 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3175 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3176 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3177 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3178 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3179 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3180 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
3181#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 7
3182
3183#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 8
3184 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3185 class t_ARGS_02,
3186 class t_ARGS_03,
3187 class t_ARGS_04,
3188 class t_ARGS_05,
3189 class t_ARGS_06,
3190 class t_ARGS_07,
3191 class t_ARGS_08>
3193 std::initializer_list<t_INIT_LIST_TYPE> il,
3194 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3195 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3196 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3197 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3198 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3199 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3200 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3201 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
3202#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 8
3203
3204#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 9
3205 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3206 class t_ARGS_02,
3207 class t_ARGS_03,
3208 class t_ARGS_04,
3209 class t_ARGS_05,
3210 class t_ARGS_06,
3211 class t_ARGS_07,
3212 class t_ARGS_08,
3213 class t_ARGS_09>
3215 std::initializer_list<t_INIT_LIST_TYPE> il,
3216 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3217 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3218 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3219 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3220 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3221 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3222 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3223 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3224 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
3225#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 9
3226
3227#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 10
3228 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3229 class t_ARGS_02,
3230 class t_ARGS_03,
3231 class t_ARGS_04,
3232 class t_ARGS_05,
3233 class t_ARGS_06,
3234 class t_ARGS_07,
3235 class t_ARGS_08,
3236 class t_ARGS_09,
3237 class t_ARGS_10>
3239 std::initializer_list<t_INIT_LIST_TYPE> il,
3240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3241 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3242 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3243 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3244 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3245 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3246 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3247 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3248 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
3249 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
3250#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_E >= 10
3251
3252# endif
3253#else
3254// The generated code below is a workaround for the absence of perfect
3255// forwarding in some compilers.
3256 template <class... t_ARGS>
3258 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
3259
3260# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3261 template <class t_INIT_LIST_TYPE, class... t_ARGS>
3263 std::initializer_list<t_INIT_LIST_TYPE> il,
3264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
3265# endif
3266// }}} END GENERATED CODE
3267#endif
3268
3269 /// These allocator-extended constructors cannot be called, and are provided
3270 /// only to prevent compilation errors when `optional` is explicitly
3271 /// instantiated.
3273
3275
3277
3279 AllocType,
3280 BloombergLP::bslmf::MovableRef<Optional_Base>);
3281
3282 template <class t_ANY_TYPE>
3284 AllocType,
3285 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
3287
3288 template <class t_ANY_TYPE>
3290 AllocType,
3291 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
3292 const Optional_Base<t_ANY_TYPE>&);
3293
3294 template <class t_ANY_TYPE>
3296 AllocType,
3297 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
3298 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>));
3299
3300#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3301// {{{ BEGIN GENERATED CODE
3302// Command line: sim_cpp11_features.pl bslstl_optional.h
3303#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
3304#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
3305#endif
3306#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_F
3307#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_F BSLSTL_OPTIONAL_VARIADIC_LIMIT
3308#endif
3309#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 0
3311 AllocType,
3313#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 0
3314
3315#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 1
3316 template <class t_ARGS_01>
3318 AllocType,
3321#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 1
3322
3323#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 2
3324 template <class t_ARGS_01,
3325 class t_ARGS_02>
3327 AllocType,
3331#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 2
3332
3333#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 3
3334 template <class t_ARGS_01,
3335 class t_ARGS_02,
3336 class t_ARGS_03>
3338 AllocType,
3343#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 3
3344
3345#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 4
3346 template <class t_ARGS_01,
3347 class t_ARGS_02,
3348 class t_ARGS_03,
3349 class t_ARGS_04>
3351 AllocType,
3357#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 4
3358
3359#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 5
3360 template <class t_ARGS_01,
3361 class t_ARGS_02,
3362 class t_ARGS_03,
3363 class t_ARGS_04,
3364 class t_ARGS_05>
3366 AllocType,
3373#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 5
3374
3375#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 6
3376 template <class t_ARGS_01,
3377 class t_ARGS_02,
3378 class t_ARGS_03,
3379 class t_ARGS_04,
3380 class t_ARGS_05,
3381 class t_ARGS_06>
3383 AllocType,
3391#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 6
3392
3393#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 7
3394 template <class t_ARGS_01,
3395 class t_ARGS_02,
3396 class t_ARGS_03,
3397 class t_ARGS_04,
3398 class t_ARGS_05,
3399 class t_ARGS_06,
3400 class t_ARGS_07>
3402 AllocType,
3411#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 7
3412
3413#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 8
3414 template <class t_ARGS_01,
3415 class t_ARGS_02,
3416 class t_ARGS_03,
3417 class t_ARGS_04,
3418 class t_ARGS_05,
3419 class t_ARGS_06,
3420 class t_ARGS_07,
3421 class t_ARGS_08>
3423 AllocType,
3433#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 8
3434
3435#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 9
3436 template <class t_ARGS_01,
3437 class t_ARGS_02,
3438 class t_ARGS_03,
3439 class t_ARGS_04,
3440 class t_ARGS_05,
3441 class t_ARGS_06,
3442 class t_ARGS_07,
3443 class t_ARGS_08,
3444 class t_ARGS_09>
3446 AllocType,
3457#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 9
3458
3459#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 10
3460 template <class t_ARGS_01,
3461 class t_ARGS_02,
3462 class t_ARGS_03,
3463 class t_ARGS_04,
3464 class t_ARGS_05,
3465 class t_ARGS_06,
3466 class t_ARGS_07,
3467 class t_ARGS_08,
3468 class t_ARGS_09,
3469 class t_ARGS_10>
3471 AllocType,
3483#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 10
3484
3485
3486# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3487#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 0
3488 template <class t_INIT_LIST_TYPE>
3490 AllocType,
3492 std::initializer_list<t_INIT_LIST_TYPE>);
3493#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 0
3494
3495#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 1
3496 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
3498 AllocType,
3500 std::initializer_list<t_INIT_LIST_TYPE>,
3502#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 1
3503
3504#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 2
3505 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3506 class t_ARGS_02>
3508 AllocType,
3510 std::initializer_list<t_INIT_LIST_TYPE>,
3513#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 2
3514
3515#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 3
3516 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3517 class t_ARGS_02,
3518 class t_ARGS_03>
3520 AllocType,
3522 std::initializer_list<t_INIT_LIST_TYPE>,
3526#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 3
3527
3528#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 4
3529 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3530 class t_ARGS_02,
3531 class t_ARGS_03,
3532 class t_ARGS_04>
3534 AllocType,
3536 std::initializer_list<t_INIT_LIST_TYPE>,
3541#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 4
3542
3543#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 5
3544 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3545 class t_ARGS_02,
3546 class t_ARGS_03,
3547 class t_ARGS_04,
3548 class t_ARGS_05>
3550 AllocType,
3552 std::initializer_list<t_INIT_LIST_TYPE>,
3558#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 5
3559
3560#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 6
3561 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3562 class t_ARGS_02,
3563 class t_ARGS_03,
3564 class t_ARGS_04,
3565 class t_ARGS_05,
3566 class t_ARGS_06>
3568 AllocType,
3570 std::initializer_list<t_INIT_LIST_TYPE>,
3577#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 6
3578
3579#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 7
3580 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3581 class t_ARGS_02,
3582 class t_ARGS_03,
3583 class t_ARGS_04,
3584 class t_ARGS_05,
3585 class t_ARGS_06,
3586 class t_ARGS_07>
3588 AllocType,
3590 std::initializer_list<t_INIT_LIST_TYPE>,
3598#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 7
3599
3600#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 8
3601 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3602 class t_ARGS_02,
3603 class t_ARGS_03,
3604 class t_ARGS_04,
3605 class t_ARGS_05,
3606 class t_ARGS_06,
3607 class t_ARGS_07,
3608 class t_ARGS_08>
3610 AllocType,
3612 std::initializer_list<t_INIT_LIST_TYPE>,
3621#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 8
3622
3623#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 9
3624 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3625 class t_ARGS_02,
3626 class t_ARGS_03,
3627 class t_ARGS_04,
3628 class t_ARGS_05,
3629 class t_ARGS_06,
3630 class t_ARGS_07,
3631 class t_ARGS_08,
3632 class t_ARGS_09>
3634 AllocType,
3636 std::initializer_list<t_INIT_LIST_TYPE>,
3646#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 9
3647
3648#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 10
3649 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3650 class t_ARGS_02,
3651 class t_ARGS_03,
3652 class t_ARGS_04,
3653 class t_ARGS_05,
3654 class t_ARGS_06,
3655 class t_ARGS_07,
3656 class t_ARGS_08,
3657 class t_ARGS_09,
3658 class t_ARGS_10>
3660 AllocType,
3662 std::initializer_list<t_INIT_LIST_TYPE>,
3673#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_F >= 10
3674
3675# endif
3676#else
3677// The generated code below is a workaround for the absence of perfect
3678// forwarding in some compilers.
3679 template <class... t_ARGS>
3681 AllocType,
3684
3685# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3686 template <class t_INIT_LIST_TYPE, class... t_ARGS>
3688 AllocType,
3690 std::initializer_list<t_INIT_LIST_TYPE>,
3692# endif
3693// }}} END GENERATED CODE
3694#endif
3695
3696 // PROTECTED MANIPULATORS
3697
3698 /// If `*this` holds an object, assign to that object the value of
3699 /// `rhs`, converted to `t_TYPE`. Otherwise, construct a held object
3700 /// from `rhs`, converted to `t_TYPE`.
3701 template <class t_ANY_TYPE>
3703
3704# ifndef BDE_OMIT_INTERNAL_DEPRECATED
3705 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
3706 ///
3707 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
3708 ///
3709 /// \note Note that this function is only intended to
3710 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use `bsl::Optional_Base`.
3711 ///
3712 /// \note Note that ref-qualified
3713 /// versions of `value()` are not provided because `NullableValue` does
3714 /// not require them.
3715 t_TYPE& dereferenceRaw();
3716
3717 // PROTECTED ACCESSORS
3718
3719 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
3720 ///
3721 /// \pre The behavior is undefined if the `Optional_Base` object is disengaged.
3722 ///
3723 /// \note Note that this function is only intended to
3724 /// be called by `bdlb::NullableValue::value` during transition of its implementation to use `bsl::Optional_Base`.
3725 ///
3726 /// \note Note that ref-qualified
3727 /// versions of `value()` are not provided because `NullableValue` does
3728 /// not require them.
3729 const t_TYPE& dereferenceRaw() const;
3730# endif // !BDE_OMIT_INTERNAL_DEPRECATED
3731
3732 public:
3733 // TYPES
3734
3735 /// `value_type` is an alias for the underlying `t_TYPE` upon which this
3736 /// template class is instantiated, and represents the type of the
3737 /// managed object. The name is chosen so it is compatible with the
3738 /// `std::optional` implementation.
3739 typedef t_TYPE value_type;
3740
3741 // TRAITS
3744 BloombergLP::bslmf::IsBitwiseMoveable,
3745 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
3748 BloombergLP::bslmf::IsBitwiseCopyable,
3749 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
3750
3751 // MANIPULATORS
3752#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3753// {{{ BEGIN GENERATED CODE
3754// Command line: sim_cpp11_features.pl bslstl_optional.h
3755#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
3756#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
3757#endif
3758#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_G
3759#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_G BSLSTL_OPTIONAL_VARIADIC_LIMIT
3760#endif
3761#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 0
3762 t_TYPE& emplace();
3763#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 0
3764
3765#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 1
3766 template <class t_ARGS_01>
3767 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
3768#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 1
3769
3770#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 2
3771 template <class t_ARGS_01,
3772 class t_ARGS_02>
3773 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3774 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
3775#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 2
3776
3777#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 3
3778 template <class t_ARGS_01,
3779 class t_ARGS_02,
3780 class t_ARGS_03>
3781 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3782 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3783 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
3784#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 3
3785
3786#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 4
3787 template <class t_ARGS_01,
3788 class t_ARGS_02,
3789 class t_ARGS_03,
3790 class t_ARGS_04>
3791 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3792 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3793 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3794 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
3795#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 4
3796
3797#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 5
3798 template <class t_ARGS_01,
3799 class t_ARGS_02,
3800 class t_ARGS_03,
3801 class t_ARGS_04,
3802 class t_ARGS_05>
3803 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3804 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3805 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3806 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3807 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
3808#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 5
3809
3810#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 6
3811 template <class t_ARGS_01,
3812 class t_ARGS_02,
3813 class t_ARGS_03,
3814 class t_ARGS_04,
3815 class t_ARGS_05,
3816 class t_ARGS_06>
3817 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3820 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3821 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3822 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
3823#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 6
3824
3825#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 7
3826 template <class t_ARGS_01,
3827 class t_ARGS_02,
3828 class t_ARGS_03,
3829 class t_ARGS_04,
3830 class t_ARGS_05,
3831 class t_ARGS_06,
3832 class t_ARGS_07>
3833 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3834 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3835 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3836 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3837 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3838 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3839 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
3840#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 7
3841
3842#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 8
3843 template <class t_ARGS_01,
3844 class t_ARGS_02,
3845 class t_ARGS_03,
3846 class t_ARGS_04,
3847 class t_ARGS_05,
3848 class t_ARGS_06,
3849 class t_ARGS_07,
3850 class t_ARGS_08>
3851 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3852 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3853 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3854 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3855 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3856 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3857 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3858 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
3859#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 8
3860
3861#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 9
3862 template <class t_ARGS_01,
3863 class t_ARGS_02,
3864 class t_ARGS_03,
3865 class t_ARGS_04,
3866 class t_ARGS_05,
3867 class t_ARGS_06,
3868 class t_ARGS_07,
3869 class t_ARGS_08,
3870 class t_ARGS_09>
3871 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3872 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3873 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3874 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3875 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3876 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3877 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3878 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3879 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
3880#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 9
3881
3882#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 10
3883 template <class t_ARGS_01,
3884 class t_ARGS_02,
3885 class t_ARGS_03,
3886 class t_ARGS_04,
3887 class t_ARGS_05,
3888 class t_ARGS_06,
3889 class t_ARGS_07,
3890 class t_ARGS_08,
3891 class t_ARGS_09,
3892 class t_ARGS_10>
3893 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3894 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3895 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3896 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3897 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3898 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3899 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
3900 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
3901 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
3902 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
3903#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 10
3904
3905
3906# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3907#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 0
3908 template <class t_INIT_LIST_TYPE>
3909 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il);
3910#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 0
3911
3912#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 1
3913 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
3914 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3915 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
3916#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 1
3917
3918#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 2
3919 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3920 class t_ARGS_02>
3921 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3922 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3923 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
3924#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 2
3925
3926#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 3
3927 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3928 class t_ARGS_02,
3929 class t_ARGS_03>
3930 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3931 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3932 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3933 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
3934#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 3
3935
3936#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 4
3937 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3938 class t_ARGS_02,
3939 class t_ARGS_03,
3940 class t_ARGS_04>
3941 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3942 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3943 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3945 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
3946#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 4
3947
3948#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 5
3949 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3950 class t_ARGS_02,
3951 class t_ARGS_03,
3952 class t_ARGS_04,
3953 class t_ARGS_05>
3954 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3955 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3956 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3957 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3958 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3959 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
3960#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 5
3961
3962#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 6
3963 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3964 class t_ARGS_02,
3965 class t_ARGS_03,
3966 class t_ARGS_04,
3967 class t_ARGS_05,
3968 class t_ARGS_06>
3969 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3970 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3971 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3972 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3973 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3974 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3975 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
3976#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 6
3977
3978#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 7
3979 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3980 class t_ARGS_02,
3981 class t_ARGS_03,
3982 class t_ARGS_04,
3983 class t_ARGS_05,
3984 class t_ARGS_06,
3985 class t_ARGS_07>
3986 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
3987 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
3988 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
3989 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
3990 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
3991 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
3992 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
3993 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
3994#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 7
3995
3996#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 8
3997 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
3998 class t_ARGS_02,
3999 class t_ARGS_03,
4000 class t_ARGS_04,
4001 class t_ARGS_05,
4002 class t_ARGS_06,
4003 class t_ARGS_07,
4004 class t_ARGS_08>
4005 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
4006 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4007 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4008 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4009 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4010 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4011 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4012 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4013 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
4014#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 8
4015
4016#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 9
4017 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4018 class t_ARGS_02,
4019 class t_ARGS_03,
4020 class t_ARGS_04,
4021 class t_ARGS_05,
4022 class t_ARGS_06,
4023 class t_ARGS_07,
4024 class t_ARGS_08,
4025 class t_ARGS_09>
4026 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
4027 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4028 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4029 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4030 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4031 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4032 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4033 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4034 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4035 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
4036#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 9
4037
4038#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 10
4039 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4040 class t_ARGS_02,
4041 class t_ARGS_03,
4042 class t_ARGS_04,
4043 class t_ARGS_05,
4044 class t_ARGS_06,
4045 class t_ARGS_07,
4046 class t_ARGS_08,
4047 class t_ARGS_09,
4048 class t_ARGS_10>
4049 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
4050 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4051 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4052 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4053 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4054 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4055 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4056 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4057 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4058 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
4059 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
4060#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_G >= 10
4061
4062# endif
4063#else
4064// The generated code below is a workaround for the absence of perfect
4065// forwarding in some compilers.
4066 template <class... t_ARGS>
4067 t_TYPE& emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
4068
4069# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4070 template <class t_INIT_LIST_TYPE, class... t_ARGS>
4071 t_TYPE& emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
4072 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
4073# endif
4074// }}} END GENERATED CODE
4075#endif
4076
4077 /// Reset this object to the default constructed state (i.e., to be in a
4078 /// disengaged state).
4080
4081 /// Efficiently exchange the value of this object with the value of the
4082 /// specified `other` object. This method provides the no-throw
4083 /// exception-safety guarantee if the template parameter `t_TYPE`
4084 /// provides that guarantee and the result of the `hasValue` method for
4085 /// the two objects being swapped is the same.
4087 bsl::is_nothrow_move_constructible<t_TYPE>::value &&
4088 bsl::is_nothrow_swappable<t_TYPE>::value);
4089
4090# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4091 /// Return a reference providing modifiable access to the underlying
4092 /// `t_TYPE` object if `true == has_value()` and throw
4093 /// `bsl::bad_optional_access` otherwise.
4094 t_TYPE& value() &;
4095 t_TYPE&& value() &&;
4096# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4097 /// Return a reference providing modifiable access to the underlying
4098 /// `t_TYPE` object. Throws a `bsl::bad_optional_access` if the
4099 /// `Optional_Base` object is disengaged.
4100 t_TYPE& value();
4101# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
4102
4103# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4104 /// Return a copy of the underlying object of a (template parameter)
4105 /// 't_TYPE' if this object is non-null, and the specified 'value' converted to 't_TYPE' otherwise.
4106 ///
4107 /// \note Note that this method returns **by
4108 /// value**, so may be inefficient in some contexts.
4109 template <class t_ANY_TYPE>
4110 t_TYPE value_or(t_ANY_TYPE&& value) &&;
4111# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4112
4113 /// Assign to this object the value of the specified `rhs` object, and
4114 /// return a non-`const` reference to this object.
4116
4117 /// Assign to this object the value of the specified `rhs` object, and
4118 /// return a non-`const` reference to this object. The allocators of this
4119 /// object and `rhs` both remain unchanged. The contents of `rhs` are
4120 /// either move-constructed into or move-assigned to this object. `rhs` is
4121 /// left in a valid but unspecified state.
4123 BloombergLP::bslmf::MovableRef<Optional_Base> rhs);
4124
4125 /// Return a pointer providing modifiable access to the underlying `t_TYPE` object.
4126 ///
4127 /// \pre The behavior is undefined if this object is disengaged.
4128 t_TYPE *operator->();
4129
4130# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4131 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
4132 ///
4133 /// \pre The behavior is undefined if this object is
4134 /// disengaged.
4135 t_TYPE& operator*() &;
4136 t_TYPE&& operator*() &&;
4137# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4138 /// Return a reference providing modifiable access to the underlying `t_TYPE` object.
4139 ///
4140 /// \pre The behavior is undefined if this object is
4141 /// disengaged.
4142 t_TYPE& operator*();
4143# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
4144
4145 // ACCESSORS
4146
4147 /// Return `false` if this object is disengaged, and `true` otherwise.
4148 bool has_value() const BSLS_KEYWORD_NOEXCEPT;
4149
4150# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4151 /// Return a reference providing non-modifiable access to the underlying
4152 /// `t_TYPE` object if `true == has_value()` and throw
4153 /// `bsl::bad_optional_access` otherwise.
4154 const t_TYPE& value() const &;
4155 const t_TYPE&& value() const &&;
4156# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4157 /// Return a reference providing non-modifiable access to the underlying
4158 /// 't_TYPE' object. Throws a 'bsl::bad_optional_access' if the
4159 /// 'Optional_Base' object is disengaged.
4160 const t_TYPE& value() const;
4161# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
4162
4163# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4164 /// Return a copy of the underlying object of a (template parameter)
4165 /// `t_TYPE` if this object is non-null, and the specified `value` converted to `t_TYPE` otherwise.
4166 ///
4167 /// \note Note that this method returns **by
4168 /// value**, so may be inefficient in some contexts.
4169 template <class t_ANY_TYPE>
4170 t_TYPE value_or(
4171 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const&;
4172# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4173 /// Return a copy of the underlying object of a (template parameter)
4174 /// `t_TYPE` if this object is non-null, and the specified `value` converted to `t_TYPE` otherwise.
4175 ///
4176 /// \note Note that this method returns **by
4177 /// value**, so may be inefficient in some contexts.
4178 template <class t_ANY_TYPE>
4179 t_TYPE value_or(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const;
4180# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
4181
4182 /// Return a pointer providing non-modifiable access to the underlying `t_TYPE` object.
4183 ///
4184 /// \pre The behavior is undefined if this object is
4185 /// disengaged.
4186 const t_TYPE *operator->() const;
4187
4188# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4189 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
4190 ///
4191 /// \pre The behavior is undefined if this object is
4192 /// disengaged.
4193 const t_TYPE& operator*() const&;
4194 const t_TYPE&& operator*() const&&;
4195# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4196 /// Return a reference providing non-modifiable access to the underlying `t_TYPE` object.
4197 ///
4198 /// \pre The behavior is undefined if this object is
4199 /// disengaged.
4200 const t_TYPE& operator*() const;
4201# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
4202
4203#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
4204 /// Return `false` if this object is disengaged, and `true` otherwise.
4205 explicit operator bool() const BSLS_KEYWORD_NOEXCEPT;
4206#else
4207 /// Simulation of explicit conversion to bool. Inlined to work around xlC
4208 /// bug when out-of-line.
4209 operator UnspecifiedBool() const BSLS_NOTHROW_SPEC
4210 {
4211 return UnspecifiedBoolUtil::makeValue(has_value());
4212 }
4213#endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT else
4214};
4215# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES else
4216
4217} // close package namespace
4218
4219
4220namespace bsl {
4221
4222// ============================================================================
4223// Section: Definition of Class Template 'optional'
4224// ============================================================================
4225
4226 // ==============
4227 // class optional
4228 // ==============
4229
4230template <class t_TYPE>
4231class optional : public BloombergLP::bslstl::Optional_Base<t_TYPE> {
4232 private:
4233 // PRIVATE TYPES
4234 typedef BloombergLP::bslstl::Optional_Base<t_TYPE> BaseType;
4235
4236 typedef typename BaseType::AllocType AllocType;
4237
4238 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
4239
4240#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
4241 // FRIENDS
4242 template <class t_ANY_TYPE> friend class optional;
4243
4244 // PRIVATE CREATORS
4245
4246 /// Create an `optional` object, which contains the result of invocation of
4247 /// the specified `invocable` with the specified `arg`.
4248 template <class t_INVOCABLE, class t_ARG>
4249 optional(BloombergLP::bslstl::Optional_InvokeConstructorTag ,
4250 t_INVOCABLE&& invocable,
4251 t_ARG&& arg);
4252#endif
4253
4254 public:
4255 // TRAITS
4257 optional,
4258 BloombergLP::bslma::UsesBslmaAllocator,
4259 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value);
4261 optional,
4262 BloombergLP::bslmf::UsesAllocatorArgT,
4263 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value);
4265 optional,
4266 BloombergLP::bslmf::IsBitwiseMoveable,
4267 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
4269 optional,
4270 BloombergLP::bslmf::IsBitwiseCopyable,
4271 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
4272
4273 // CREATORS
4274
4275 /// Create a disengaged `optional` object. Use the currently installed
4276 /// default allocator to supply memory. This constructor can be called in
4277 /// constant expressions only when `t_TYPE` is not allocator-aware.
4279
4280 /// Create a disengaged `optional` object. Use the currently installed
4281 /// default allocator to supply memory. This constructor can be called in
4282 /// constant expressions only when `t_TYPE` is not allocator-aware.
4284 optional(bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT; // IMPLICIT
4285
4286#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
4287 /// If the `optional` base class of the specified `original` holds a
4288 /// value, create an `optional` object whose contained value is
4289 /// initialized by moving from that value; otherwise, create a
4290 /// disengaged `optional` object. The allocator associated with the
4291 /// `optional` base class of `original` is propagated for use in the
4292 /// newly-created object. `original` is left in a valid, but unspecified state.
4293 ///
4294 /// \note Note that this constructor does not participate
4295 /// in overload resolution unless `optional` is an accessible base class
4296 /// of `t_DERIVED` or `t_DERIVED` is `optional` itself (in which case
4297 /// the instantiation provides the move constructor in C++03; a move
4298 /// constructor is implicitly declared in C++11).
4299 template <class t_DERIVED>
4300 optional(BloombergLP::bslmf::MovableRef<t_DERIVED> original,
4304#endif
4305
4306 /// Create an `optional` object whose contained value is initialized by
4307 /// forwarding from the specified `value`. Use the currently installed default allocator to supply memory.
4308 ///
4309 /// \note Note that this constructor
4310 /// participates in overload resolution only when `t_TYPE` is
4311 /// constructible from `t_ANY_TYPE` and is implicit only when
4312 /// `t_ANY_TYPE` is implicitly convertible to `t_TYPE`. This constructor
4313 /// can be called in constant expressions only when `t_TYPE` is not
4314 /// allocator-aware.
4315 template <class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
4320 t_ANY_TYPE));
4321 // IMPLICIT
4322 template <class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
4324 explicit optional(
4325 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
4328
4329 /// Create a disengaged `optional` object if the specified `original`
4330 /// object is disengaged, and an `optional` object with the value of
4331 /// `original.value()` converted to `t_TYPE` otherwise. Use the
4332 /// currently installed default allocator to supply memory.
4333 ///
4334 /// \note Note that this constructor participates in overload resolution only when
4335 /// `t_TYPE` is constructible from an lvalue of `const t_ANY_TYPE`, and
4336 /// is implicit only when an lvalue of `const t_ANY_TYPE` is implicitly
4337 /// convertible to `t_TYPE`. This constructor can be called in constant
4338 /// expressions only when neither `t_TYPE` nor `t_ANY_TYPE` is
4339 /// allocator-aware.
4340 template <class t_ANY_TYPE>
4342 const optional<t_ANY_TYPE>& original,
4344 t_TYPE,
4345 const t_ANY_TYPE&),
4347 const t_ANY_TYPE&));
4348 // IMPLICIT
4349 template <class t_ANY_TYPE>
4351 const optional<t_ANY_TYPE>& original,
4353 t_TYPE,
4354 const t_ANY_TYPE&),
4356 const t_ANY_TYPE&));
4357
4358 /// Create a disengaged `optional` object if the specified `original`
4359 /// object is disengaged, and an `optional` object with the value of
4360 /// `original.value()` moved and converted to `t_TYPE` otherwise. Use
4361 /// the allocator from `original` to supply memory if `t_ANY_TYPE` is a
4362 /// non-const version of `t_TYPE`; otherwise, use the currently
4363 /// installed default allocator. `original` is left in a valid but unspecified state.
4364 ///
4365 /// \note Note that this constructor participates in
4366 /// overload resolution only when `t_TYPE` is constructible from an
4367 /// xvalue of `t_ANY_TYPE`, and is implicit only when an xvalue of
4368 /// `t_ANY_TYPE` is implicitly convertible to `t_TYPE`. This constructor
4369 /// can be called in constant expressions only when neither `t_TYPE` nor
4370 /// `t_ANY_TYPE` is allocator-aware.
4371 template <class t_ANY_TYPE>
4373 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
4375 t_ANY_TYPE),
4377 // IMPLICIT
4378 template <class t_ANY_TYPE>
4380 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
4382 t_ANY_TYPE),
4384
4385# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
4386 /// Create a disengaged `optional` object if the specified `original`
4387 /// object is disengaged, and an `optional` object with the value of
4388 /// `original.value()` converted to `t_TYPE` otherwise. Use the
4389 /// currently installed default allocator to supply memory.
4390 ///
4391 /// \note Note that this constructor participates in overload resolution only when
4392 /// `t_TYPE` is constructible from an lvalue of `const t_ANY_TYPE`, and
4393 /// is implicit only when an lvalue of `const t_ANY_TYPE` is implicitly
4394 /// convertible to `t_TYPE`. This constructor can be called in constant
4395 /// expressions only when `t_TYPE` is not allocator-aware.
4396 template <class t_ANY_TYPE>
4398 const std::optional<t_ANY_TYPE>& original,
4400 t_TYPE,
4401 const t_ANY_TYPE&),
4403 t_ANY_TYPE));
4404 // IMPLICIT
4405 template <class t_ANY_TYPE>
4407 const std::optional<t_ANY_TYPE>& original,
4409 t_TYPE,
4410 const t_ANY_TYPE&),
4412
4413 /// Create a disengaged `optional` object if the specified `original`
4414 /// object is disengaged, and an `optional` object with the value of
4415 /// `original.value()` converted to `t_TYPE` otherwise. Use the
4416 /// currently installed default allocator to supply memory.
4417 ///
4418 /// \note Note that this constructor participates in overload resolution only when
4419 /// `t_TYPE` is constructible from an xvalue of `t_ANY_TYPE`, and is
4420 /// implicit only when an xvalue of `t_ANY_TYPE` is implicitly
4421 /// convertible to `t_TYPE`. This constructor can be called in constant
4422 /// expressions only when `t_TYPE` is not allocator-aware.
4423 template <class t_ANY_TYPE>
4425 std::optional<t_ANY_TYPE>&& original,
4427 t_ANY_TYPE),
4429 // IMPLICIT
4430 template <class t_ANY_TYPE>
4432 std::optional<t_ANY_TYPE>&& original,
4434 t_ANY_TYPE),
4436# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
4437
4438#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4439// {{{ BEGIN GENERATED CODE
4440// Command line: sim_cpp11_features.pl bslstl_optional.h
4441#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
4442#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
4443#endif
4444#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_H
4445#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_H BSLSTL_OPTIONAL_VARIADIC_LIMIT
4446#endif
4447#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 0
4450#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 0
4451
4452#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 1
4453 template <class t_ARGS_01>
4456 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
4457#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 1
4458
4459#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 2
4460 template <class t_ARGS_01,
4461 class t_ARGS_02>
4464 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4465 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
4466#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 2
4467
4468#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 3
4469 template <class t_ARGS_01,
4470 class t_ARGS_02,
4471 class t_ARGS_03>
4474 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4475 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4476 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
4477#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 3
4478
4479#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 4
4480 template <class t_ARGS_01,
4481 class t_ARGS_02,
4482 class t_ARGS_03,
4483 class t_ARGS_04>
4486 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4487 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4488 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4489 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
4490#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 4
4491
4492#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 5
4493 template <class t_ARGS_01,
4494 class t_ARGS_02,
4495 class t_ARGS_03,
4496 class t_ARGS_04,
4497 class t_ARGS_05>
4500 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4501 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4502 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4503 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4504 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
4505#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 5
4506
4507#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 6
4508 template <class t_ARGS_01,
4509 class t_ARGS_02,
4510 class t_ARGS_03,
4511 class t_ARGS_04,
4512 class t_ARGS_05,
4513 class t_ARGS_06>
4516 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4517 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4518 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4519 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4520 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4521 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
4522#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 6
4523
4524#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 7
4525 template <class t_ARGS_01,
4526 class t_ARGS_02,
4527 class t_ARGS_03,
4528 class t_ARGS_04,
4529 class t_ARGS_05,
4530 class t_ARGS_06,
4531 class t_ARGS_07>
4534 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4535 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4536 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4537 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4538 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4539 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4540 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
4541#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 7
4542
4543#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 8
4544 template <class t_ARGS_01,
4545 class t_ARGS_02,
4546 class t_ARGS_03,
4547 class t_ARGS_04,
4548 class t_ARGS_05,
4549 class t_ARGS_06,
4550 class t_ARGS_07,
4551 class t_ARGS_08>
4554 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4555 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4556 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4557 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4558 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4559 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4560 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4561 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
4562#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 8
4563
4564#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 9
4565 template <class t_ARGS_01,
4566 class t_ARGS_02,
4567 class t_ARGS_03,
4568 class t_ARGS_04,
4569 class t_ARGS_05,
4570 class t_ARGS_06,
4571 class t_ARGS_07,
4572 class t_ARGS_08,
4573 class t_ARGS_09>
4576 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4577 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4578 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4579 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4580 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4581 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4582 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4583 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4584 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
4585#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 9
4586
4587#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 10
4588 template <class t_ARGS_01,
4589 class t_ARGS_02,
4590 class t_ARGS_03,
4591 class t_ARGS_04,
4592 class t_ARGS_05,
4593 class t_ARGS_06,
4594 class t_ARGS_07,
4595 class t_ARGS_08,
4596 class t_ARGS_09,
4597 class t_ARGS_10>
4600 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4601 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4602 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4603 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4604 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4605 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4606 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4607 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4608 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
4609 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
4610#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 10
4611
4612
4613# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4614#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 0
4615 template <class t_INIT_LIST_TYPE>
4618 std::initializer_list<t_INIT_LIST_TYPE> il);
4619#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 0
4620
4621#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 1
4622 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
4625 std::initializer_list<t_INIT_LIST_TYPE> il,
4626 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
4627#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 1
4628
4629#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 2
4630 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4631 class t_ARGS_02>
4634 std::initializer_list<t_INIT_LIST_TYPE> il,
4635 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4636 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
4637#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 2
4638
4639#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 3
4640 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4641 class t_ARGS_02,
4642 class t_ARGS_03>
4645 std::initializer_list<t_INIT_LIST_TYPE> il,
4646 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4647 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4648 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
4649#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 3
4650
4651#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 4
4652 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4653 class t_ARGS_02,
4654 class t_ARGS_03,
4655 class t_ARGS_04>
4658 std::initializer_list<t_INIT_LIST_TYPE> il,
4659 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4660 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4661 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4662 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
4663#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 4
4664
4665#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 5
4666 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4667 class t_ARGS_02,
4668 class t_ARGS_03,
4669 class t_ARGS_04,
4670 class t_ARGS_05>
4673 std::initializer_list<t_INIT_LIST_TYPE> il,
4674 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4675 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4676 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4677 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4678 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
4679#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 5
4680
4681#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 6
4682 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4683 class t_ARGS_02,
4684 class t_ARGS_03,
4685 class t_ARGS_04,
4686 class t_ARGS_05,
4687 class t_ARGS_06>
4690 std::initializer_list<t_INIT_LIST_TYPE> il,
4691 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4692 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4693 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4694 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4695 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4696 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
4697#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 6
4698
4699#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 7
4700 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4701 class t_ARGS_02,
4702 class t_ARGS_03,
4703 class t_ARGS_04,
4704 class t_ARGS_05,
4705 class t_ARGS_06,
4706 class t_ARGS_07>
4709 std::initializer_list<t_INIT_LIST_TYPE> il,
4710 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4711 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4712 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4713 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4714 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4715 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4716 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
4717#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 7
4718
4719#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 8
4720 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4721 class t_ARGS_02,
4722 class t_ARGS_03,
4723 class t_ARGS_04,
4724 class t_ARGS_05,
4725 class t_ARGS_06,
4726 class t_ARGS_07,
4727 class t_ARGS_08>
4730 std::initializer_list<t_INIT_LIST_TYPE> il,
4731 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4732 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4733 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4734 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4735 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4736 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4737 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4738 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
4739#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 8
4740
4741#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 9
4742 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4743 class t_ARGS_02,
4744 class t_ARGS_03,
4745 class t_ARGS_04,
4746 class t_ARGS_05,
4747 class t_ARGS_06,
4748 class t_ARGS_07,
4749 class t_ARGS_08,
4750 class t_ARGS_09>
4753 std::initializer_list<t_INIT_LIST_TYPE> il,
4754 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4755 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4756 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4757 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4758 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4759 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4760 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4761 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4762 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
4763#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 9
4764
4765#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 10
4766 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
4767 class t_ARGS_02,
4768 class t_ARGS_03,
4769 class t_ARGS_04,
4770 class t_ARGS_05,
4771 class t_ARGS_06,
4772 class t_ARGS_07,
4773 class t_ARGS_08,
4774 class t_ARGS_09,
4775 class t_ARGS_10>
4778 std::initializer_list<t_INIT_LIST_TYPE> il,
4779 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
4780 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
4781 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
4782 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
4783 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
4784 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
4785 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
4786 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
4787 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
4788 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
4789#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_H >= 10
4790
4791#endif
4792#else
4793// The generated code below is a workaround for the absence of perfect
4794// forwarding in some compilers.
4795 template <class... t_ARGS>
4798 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
4799
4800# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4801 template <class t_INIT_LIST_TYPE, class... t_ARGS>
4804 std::initializer_list<t_INIT_LIST_TYPE> il,
4805 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
4806#endif
4807// }}} END GENERATED CODE
4808#endif
4809
4810 // These allocator-extended constructors can be called only when 't_TYPE'
4811 // is allocator-aware.
4812
4813 /// Create a disengaged `optional` object. Use the specified
4814 /// `allocator` to supply memory.
4815 optional(bsl::allocator_arg_t, AllocType allocator);
4816
4817 /// Create a disengaged `optional` object. Use the specified
4818 /// `allocator` to supply memory.
4819 optional(bsl::allocator_arg_t, AllocType allocator, bsl::nullopt_t);
4820
4821 /// If the specified `original` contains a value, create an `optional`
4822 /// object whose contained value is initialized from `*original`;
4823 /// otherwise, create a disengaged `optional` object. Use the specified
4824 /// `allocator` to supply memory.
4826 AllocType allocator,
4827 const optional& original);
4828
4829 /// If the `optional` base class of the specified `original` holds a
4830 /// value, create an `optional` object whose contained value is
4831 /// initialized by moving from that value; otherwise, create a
4832 /// disengaged `optional` object. Use the specified `allocator` to
4833 /// supply memory. `original` is left in a valid, but unspecified state.
4834 ///
4835 /// \note Note that this constructor does not participate in overload
4836 /// resolution unless `optional` is an accessible base class of
4837 /// `t_DERIVED` or `t_DERIVED` is `optional` itself (in which case the
4838 /// instantiation provides the allocator-extended move constructor).
4839 template <class t_DERIVED>
4841 AllocType allocator,
4842 BSLMF_MOVABLEREF_DEDUCE(t_DERIVED) original,
4845
4846 /// Create an `optional` object whose contained value is initialized by
4847 /// forwarding from the specified `value`. Use the specified `allocator` to supply memory.
4848 ///
4849 /// \note Note that this constructor
4850 /// participates in overload resolution only when `t_TYPE` is
4851 /// constructible from `t_ANY_TYPE`, and is implicit only when
4852 /// `t_ANY_TYPE` is implicitly convertible to `t_TYPE`.
4853 template <class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
4855 AllocType allocator,
4856 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
4859 t_ANY_TYPE));
4860 template <class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
4861 explicit optional(
4863 AllocType allocator,
4864 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
4867
4868 /// Create a disengaged `optional` object if the specified `original`
4869 /// object is disengaged, and an `optional` object with the value of
4870 /// `original.value()` converted to `t_TYPE` otherwise. Use the specified `allocator` to supply memory.
4871 ///
4872 /// \note Note that this constructor
4873 /// participates in overload resolution only when `t_TYPE` is
4874 /// constructible from an lvalue of `const t_ANY_TYPE`, and is implicit
4875 /// only when an lvalue of `const t_ANY_TYPE` is implicitly convertible
4876 /// to `t_TYPE`.
4877 template <class t_ANY_TYPE>
4878 optional(
4880 AllocType allocator,
4881 const optional<t_ANY_TYPE>& original,
4883 t_TYPE,
4884 const t_ANY_TYPE&),
4886 const t_ANY_TYPE&));
4887 template <class t_ANY_TYPE>
4888 explicit optional(
4890 AllocType allocator,
4891 const optional<t_ANY_TYPE>& original,
4893 t_TYPE,
4894 const t_ANY_TYPE&),
4896 const t_ANY_TYPE&));
4897
4898 /// Create a disengaged `optional` object if the specified `original`
4899 /// object is disengaged, and an `optional` object with the value of
4900 /// `original.value()` moved and converted to `t_TYPE` otherwise. Use
4901 /// the specified `allocator` to supply memory. `original` is left in a valid but unspecified state.
4902 ///
4903 /// \note Note that this constructor
4904 /// participates in overload resolution only when `t_TYPE` is
4905 /// constructible from an xvalue of `t_ANY_TYPE`, and is implicit only
4906 /// when an xvalue of `t_ANY_TYPE` is implicitly convertible to
4907 /// `t_TYPE`.
4908 template <class t_ANY_TYPE>
4909 optional(
4911 AllocType allocator,
4912 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
4914 t_ANY_TYPE),
4916 template <class t_ANY_TYPE>
4917 explicit optional(
4919 AllocType allocator,
4920 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
4922 t_ANY_TYPE),
4924
4925# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
4926 /// Create a disengaged `optional` object if the specified `original`
4927 /// object is disengaged, and an `optional` object with the value of
4928 /// `original.value()` converted to `t_TYPE` otherwise. Use the specified `allocator` to supply memory.
4929 ///
4930 /// \note Note that this constructor
4931 /// participates in overload resolution only when `t_TYPE` is
4932 /// constructible from an lvalue of `const t_ANY_TYPE`, and is implicit
4933 /// only when an lvalue of `const t_ANY_TYPE` is implicitly convertible
4934 /// to `t_TYPE`.
4935 template <class t_ANY_TYPE>
4936 optional(
4938 AllocType allocator,
4939 const std::optional<t_ANY_TYPE>& original,
4941 t_TYPE,
4942 const t_ANY_TYPE&),
4944 const t_ANY_TYPE&));
4945 template <class t_ANY_TYPE>
4946 explicit optional(
4948 AllocType allocator,
4949 const std::optional<t_ANY_TYPE>& original,
4951 t_TYPE,
4952 const t_ANY_TYPE&),
4954 const t_ANY_TYPE));
4955
4956 /// Create a disengaged `optional` object if the specified `original`
4957 /// object is disengaged, and an `optional` object with the value of
4958 /// `original.value()` moved and converted to `t_TYPE` otherwise. Use
4959 /// the specified `allocator` to supply memory. `original` is left in a valid but unspecified state.
4960 ///
4961 /// \note Note that this constructor
4962 /// participates in overload resolution only when `t_TYPE` is
4963 /// constructible from an xvalue of `t_ANY_TYPE`, and is implicit only
4964 /// when an xvalue of `t_ANY_TYPE` is implicitly convertible to
4965 /// `t_TYPE`.
4966 template <class t_ANY_TYPE>
4967 optional(
4969 AllocType allocator,
4970 std::optional<t_ANY_TYPE>&& original,
4972 t_ANY_TYPE),
4974 template <class t_ANY_TYPE>
4975 explicit optional(
4977 AllocType allocator,
4978 std::optional<t_ANY_TYPE>&& original,
4980 t_ANY_TYPE),
4982# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
4983
4984#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4985// {{{ BEGIN GENERATED CODE
4986// Command line: sim_cpp11_features.pl bslstl_optional.h
4987#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
4988#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
4989#endif
4990#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_I
4991#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_I BSLSTL_OPTIONAL_VARIADIC_LIMIT
4992#endif
4993#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 0
4995 AllocType allocator,
4997#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 0
4998
4999#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 1
5000 template <class t_ARGS_01>
5002 AllocType allocator,
5004 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
5005#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 1
5006
5007#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 2
5008 template <class t_ARGS_01,
5009 class t_ARGS_02>
5011 AllocType allocator,
5013 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5014 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
5015#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 2
5016
5017#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 3
5018 template <class t_ARGS_01,
5019 class t_ARGS_02,
5020 class t_ARGS_03>
5022 AllocType allocator,
5024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5026 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
5027#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 3
5028
5029#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 4
5030 template <class t_ARGS_01,
5031 class t_ARGS_02,
5032 class t_ARGS_03,
5033 class t_ARGS_04>
5035 AllocType allocator,
5037 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5038 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5039 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5040 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
5041#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 4
5042
5043#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 5
5044 template <class t_ARGS_01,
5045 class t_ARGS_02,
5046 class t_ARGS_03,
5047 class t_ARGS_04,
5048 class t_ARGS_05>
5050 AllocType allocator,
5052 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5053 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5054 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5055 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5056 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
5057#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 5
5058
5059#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 6
5060 template <class t_ARGS_01,
5061 class t_ARGS_02,
5062 class t_ARGS_03,
5063 class t_ARGS_04,
5064 class t_ARGS_05,
5065 class t_ARGS_06>
5067 AllocType allocator,
5069 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5070 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5071 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5072 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5073 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5074 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
5075#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 6
5076
5077#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 7
5078 template <class t_ARGS_01,
5079 class t_ARGS_02,
5080 class t_ARGS_03,
5081 class t_ARGS_04,
5082 class t_ARGS_05,
5083 class t_ARGS_06,
5084 class t_ARGS_07>
5086 AllocType allocator,
5088 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5089 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5090 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5091 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5092 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5093 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5094 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
5095#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 7
5096
5097#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 8
5098 template <class t_ARGS_01,
5099 class t_ARGS_02,
5100 class t_ARGS_03,
5101 class t_ARGS_04,
5102 class t_ARGS_05,
5103 class t_ARGS_06,
5104 class t_ARGS_07,
5105 class t_ARGS_08>
5107 AllocType allocator,
5109 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5110 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5112 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5113 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5114 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5115 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5116 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
5117#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 8
5118
5119#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 9
5120 template <class t_ARGS_01,
5121 class t_ARGS_02,
5122 class t_ARGS_03,
5123 class t_ARGS_04,
5124 class t_ARGS_05,
5125 class t_ARGS_06,
5126 class t_ARGS_07,
5127 class t_ARGS_08,
5128 class t_ARGS_09>
5130 AllocType allocator,
5132 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5133 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5134 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5135 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5136 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5137 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5138 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5139 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
5140 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
5141#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 9
5142
5143#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 10
5144 template <class t_ARGS_01,
5145 class t_ARGS_02,
5146 class t_ARGS_03,
5147 class t_ARGS_04,
5148 class t_ARGS_05,
5149 class t_ARGS_06,
5150 class t_ARGS_07,
5151 class t_ARGS_08,
5152 class t_ARGS_09,
5153 class t_ARGS_10>
5155 AllocType allocator,
5157 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5158 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5159 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5160 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5161 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5162 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5163 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5164 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
5165 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
5166 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
5167#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 10
5168
5169
5170# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5171#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 0
5172 template <class t_INIT_LIST_TYPE>
5174 AllocType allocator,
5176 std::initializer_list<t_INIT_LIST_TYPE> il);
5177#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 0
5178
5179#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 1
5180 template <class t_INIT_LIST_TYPE, class t_ARGS_01>
5182 AllocType allocator,
5184 std::initializer_list<t_INIT_LIST_TYPE> il,
5185 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
5186#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 1
5187
5188#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 2
5189 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5190 class t_ARGS_02>
5192 AllocType allocator,
5194 std::initializer_list<t_INIT_LIST_TYPE> il,
5195 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5196 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
5197#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 2
5198
5199#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 3
5200 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5201 class t_ARGS_02,
5202 class t_ARGS_03>
5204 AllocType allocator,
5206 std::initializer_list<t_INIT_LIST_TYPE> il,
5207 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5208 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5209 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
5210#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 3
5211
5212#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 4
5213 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5214 class t_ARGS_02,
5215 class t_ARGS_03,
5216 class t_ARGS_04>
5218 AllocType allocator,
5220 std::initializer_list<t_INIT_LIST_TYPE> il,
5221 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5222 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5223 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5224 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
5225#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 4
5226
5227#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 5
5228 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5229 class t_ARGS_02,
5230 class t_ARGS_03,
5231 class t_ARGS_04,
5232 class t_ARGS_05>
5234 AllocType allocator,
5236 std::initializer_list<t_INIT_LIST_TYPE> il,
5237 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5238 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5239 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5241 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
5242#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 5
5243
5244#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 6
5245 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5246 class t_ARGS_02,
5247 class t_ARGS_03,
5248 class t_ARGS_04,
5249 class t_ARGS_05,
5250 class t_ARGS_06>
5252 AllocType allocator,
5254 std::initializer_list<t_INIT_LIST_TYPE> il,
5255 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5256 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5257 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5258 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5259 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5260 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
5261#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 6
5262
5263#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 7
5264 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5265 class t_ARGS_02,
5266 class t_ARGS_03,
5267 class t_ARGS_04,
5268 class t_ARGS_05,
5269 class t_ARGS_06,
5270 class t_ARGS_07>
5272 AllocType allocator,
5274 std::initializer_list<t_INIT_LIST_TYPE> il,
5275 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5276 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5277 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5278 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5279 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5280 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
5282#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 7
5283
5284#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 8
5285 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5286 class t_ARGS_02,
5287 class t_ARGS_03,
5288 class t_ARGS_04,
5289 class t_ARGS_05,
5290 class t_ARGS_06,
5291 class t_ARGS_07,
5292 class t_ARGS_08>
5294 AllocType allocator,
5296 std::initializer_list<t_INIT_LIST_TYPE> il,
5297 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5298 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5299 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5300 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5301 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5302 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5303 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5304 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
5305#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 8
5306
5307#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 9
5308 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5309 class t_ARGS_02,
5310 class t_ARGS_03,
5311 class t_ARGS_04,
5312 class t_ARGS_05,
5313 class t_ARGS_06,
5314 class t_ARGS_07,
5315 class t_ARGS_08,
5316 class t_ARGS_09>
5318 AllocType allocator,
5320 std::initializer_list<t_INIT_LIST_TYPE> il,
5321 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5322 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5323 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5324 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5325 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5326 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5327 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5328 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
5329 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
5330#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 9
5331
5332#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 10
5333 template <class t_INIT_LIST_TYPE, class t_ARGS_01,
5334 class t_ARGS_02,
5335 class t_ARGS_03,
5336 class t_ARGS_04,
5337 class t_ARGS_05,
5338 class t_ARGS_06,
5339 class t_ARGS_07,
5340 class t_ARGS_08,
5341 class t_ARGS_09,
5342 class t_ARGS_10>
5344 AllocType allocator,
5346 std::initializer_list<t_INIT_LIST_TYPE> il,
5347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
5348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
5349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
5350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
5351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
5352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
5353 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
5354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
5355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
5356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
5357#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_I >= 10
5358
5359# endif
5360#else
5361// The generated code below is a workaround for the absence of perfect
5362// forwarding in some compilers.
5363 template <class... t_ARGS>
5365 AllocType allocator,
5367 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
5368
5369# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5370 template <class t_INIT_LIST_TYPE, class... t_ARGS>
5372 AllocType allocator,
5374 std::initializer_list<t_INIT_LIST_TYPE> il,
5375 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
5376# endif
5377// }}} END GENERATED CODE
5378#endif
5379
5380 // MANIPULATORS
5381
5382 // We implement 'operator=' in the most derived class to avoid having to
5383 // repeat constraints in each of the three implementations of
5384 // 'Optional_Base'.
5385
5386 /// Reset this object to be disengaged and return a reference providing
5387 /// modifiable access to this object. This assignment operator can be
5388 /// called in constant expressions only when `t_TYPE` is not
5389 /// allocator-aware.
5392
5393#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5394 /// If the `optional` base class of the specified `rhs` holds a value,
5395 /// move-construct or move-assign the contained value of `*this` from
5396 /// that value. Otherwise, set `*this` to be disengaged. Return a
5397 /// reference providing modifiable access to this object. `rhs` is left
5398 /// in a valid but unspecified state. This method does not participate
5399 /// in overload resolution unless `optional` is an accessible base class
5400 /// of `t_DERIVED` or `t_DERIVED` is `optional` itself (in which case
5401 /// the instantiation provides the move assignment operator in C++03; a
5402 /// move assignment operator is implicitly declared in C++11).
5403 template <class t_DERIVED>
5405 operator=(BloombergLP::bslmf::MovableRef<t_DERIVED> rhs);
5406#endif
5407
5408 /// Disengage this object if the specified `rhs` object is disengaged,
5409 /// and assign to this object the value of `rhs.value()` (of
5410 /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference providing modifiable access to this object.
5411 ///
5412 /// \note Note that this method
5413 /// does not participate in overload resolution unless `t_TYPE` and
5414 /// `t_ANY_TYPE` are compatible. This assignment operator can be called in
5415 /// constant expressions only when neither `t_TYPE` nor `t_ANY_TYPE` is
5416 /// allocator-aware.
5417 template <class t_ANY_TYPE>
5419 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE&)&
5420 operator=(const optional<t_ANY_TYPE>& rhs);
5421
5422 /// Disengage this object if the specified `rhs` object is disengaged,
5423 /// and move assign to this object the value of `rhs.value()` (of
5424 /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference providing modifiable access to this object.
5425 ///
5426 /// \note Note that this method
5427 /// does not participate in overload resolution unless `t_TYPE` and
5428 /// `t_ANY_TYPE` are compatible. This assignment operator can be called in
5429 /// constant expressions only when neither `t_TYPE` nor `t_ANY_TYPE` is
5430 /// allocator-aware.
5431 template <class t_ANY_TYPE>
5434 operator=(BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) rhs);
5435
5436#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5437 /// Assign to this object the value of the specified `rhs` object
5438 /// converted to `t_TYPE`, and return a reference providing modifiable access to this object.
5439 ///
5440 /// \note Note that this method may invoke assignment
5441 /// from `rhs`, or construction from `rhs`, depending on whether this
5442 /// object is engaged. This assignment operator does not participate in
5443 /// overload resolution if `t_ANY_TYPE` is possibly cv-qualified
5444 /// `bsl::optional<t_TYPE>`. Also note that an assignment of the form
5445 /// `o = {};`, where `o` is of type `optional`, will always assign to
5446 /// `o` the empty state, and never call this overload (see
5447 /// implementation notes). This assignment operator can be called in
5448 /// constant expressions only when `t_TYPE` is not allocator-aware.
5449 template <class t_ANY_TYPE = t_TYPE>
5452 operator=(t_ANY_TYPE&& rhs);
5453#else
5454 // The existence of MovableRef in C++11 affects the above functions, and
5455 // they need to be defined in terms of rvalue references and perfect
5456 // forwarding. For C++03, the MovableRef overloads are provided below.
5457
5458 /// Assign to this object the value of the specified `rhs`, and return a
5459 /// reference providing modifiable access to this object.
5460 optional& operator=(const t_TYPE& rhs);
5461
5462 /// Assign to this object the value of the specified `rhs`, and return a
5463 /// reference providing modifiable access to this object. The contents
5464 /// of `rhs` are either move-constructed into or move-assigned to this
5465 /// object. `rhs` is left in a valid but unspecified state.
5466 optional& operator=(BloombergLP::bslmf::MovableRef<t_TYPE> rhs);
5467
5468 /// Assign to this object the value of the specified `rhs` object (of
5469 /// `ANY_TYPE`) converted to `TYPE`, and return a reference providing modifiable access to this object.
5470 ///
5471 /// \note Note that this method may invoke
5472 /// assignment from `rhs`, or construction from `rhs`, depending on
5473 /// whether this `optional` object is engaged.
5474 template <class t_ANY_TYPE>
5476 operator=(const t_ANY_TYPE& rhs);
5477
5478 template <class t_ANY_TYPE>
5480 operator=(BloombergLP::bslmf::MovableRef<t_ANY_TYPE> rhs);
5481#endif // RVALUES else
5482
5483#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
5484 /// Disengage this object if the specified `rhs` object is disengaged,
5485 /// and assign to this object the value of `rhs.value()` (of
5486 /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference providing modifiable access to this object.
5487 ///
5488 /// \note Note that this method
5489 /// does not participate in overload resolution unless `t_TYPE` and
5490 /// `t_ANY_TYPE` are compatible. This assignment operator can be called in
5491 /// constant expressions only when `t_TYPE` is not allocator-aware.
5492 template <class t_ANY_TYPE = t_TYPE>
5494 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, const t_ANY_TYPE&)&
5495 operator=(const std::optional<t_ANY_TYPE>& rhs);
5496
5497 /// Disengage this object if the specified `rhs` object is disengaged,
5498 /// and move assign to this object the value of `rhs.value()` (of
5499 /// `t_ANY_TYPE`) converted to `t_TYPE` otherwise. Return a reference providing modifiable access to this object.
5500 ///
5501 /// \note Note that this method
5502 /// does not participate in overload resolution unless `t_TYPE` and
5503 /// `t_ANY_TYPE` are compatible. This assignment operator can be called in
5504 /// constant expressions only when `t_TYPE` is not allocator-aware.
5505 template <class t_ANY_TYPE = t_TYPE>
5508 operator=(std::optional<t_ANY_TYPE>&& rhs);
5509# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
5510
5511#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
5512
5513 // This macro indicates that `bsl::optional` provides @ref and_then ,
5514 // `or_else`, and `transform` methods.
5515 #define BSLSTL_OPTIONAL_PROVIDES_MONADICS
5516
5517 /// If this object contains a value, invoke the specified `func` with the
5518 /// contained value as an argument and return `optional<U>` that contains
5519 /// the result of that invocation, where `U` is the cv-unqualified `func`
5520 /// return type, which can be different from `t_TYPE`; otherwise, return an empty `optional<U>`.
5521 ///
5522 /// \note Note that `func` must return an object type other
5523 /// than array, `bsl::in_place_t` or `bsl::nullopt`. Also note that there
5524 /// is no requirement that `U` is movable. Finally note that the returned
5525 /// optional uses the allocator of the object returned by `func`, or the
5526 /// default allocator if `func` is not invoked.
5527 template <class t_FUNC> constexpr auto transform(t_FUNC&& func) &;
5528 template <class t_FUNC> constexpr auto transform(t_FUNC&& func) &&;
5529 template <class t_FUNC> constexpr auto transform(t_FUNC&& func) const &;
5530 template <class t_FUNC> constexpr auto transform(t_FUNC&& func) const &&;
5531
5532 /// If this object contains a value, invoke the specified `func` with the
5533 /// contained value as an argument and return the result of that invocation; otherwise, return an empty optional.
5534 ///
5535 /// \note Note that `func` must
5536 /// return a specialization of `bsl::optional`. Also note that the return
5537 /// type of `func` does not have to be this object type. Also note that
5538 /// the optional object returned by `func` is returned as-is, without
5539 /// copying or moving. Finally note that the default allocator is used for
5540 /// constructing the empty optional when `func` is not invoked.
5541 template <class t_FUNC> constexpr auto and_then(t_FUNC&& func) &;
5542 template <class t_FUNC> constexpr auto and_then(t_FUNC&& func) &&;
5543 template <class t_FUNC> constexpr auto and_then(t_FUNC&& func) const &;
5544 template <class t_FUNC> constexpr auto and_then(t_FUNC&& func) const &&;
5545
5546 /// If this object does not contain a value, invoke the specified `func`
5547 /// and return the result of that invocation. Otherwise return a copy-constructed value from this object.
5548 ///
5549 /// \note Note that `func` must return
5550 /// `bsl::optional`. Also note that the optional object returned by `func`
5551 /// is returned as-is, without copying or moving.
5552 template <class t_FUNC>
5553 constexpr
5554 enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
5555 std::is_copy_constructible<t_TYPE>>,
5556 optional> or_else(t_FUNC&& func) const &;
5557
5558 /// If this object does not contain a value, invoke the specified `func`
5559 /// and return the result of that invocation; otherwise, return a
5560 /// move-constructed value from this object, leaving this object in an unspecified but valid state.
5561 ///
5562 /// \note Note that `func` must return
5563 /// `bsl::optional`. Also note that the optional object returned by `func`
5564 /// is returned as-is, without copying or moving.
5565 template <class t_FUNC>
5566 constexpr
5567 enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
5568 std::is_move_constructible<t_TYPE>>,
5569 optional> or_else(t_FUNC&& func) &&;
5570#endif
5571};
5572
5573} // close namespace bsl
5574
5575// ============================================================================
5576// Section: Type Traits on Allocator-Unaware 'Optional_Base'
5577// ============================================================================
5578
5579
5580namespace bslma {
5581
5582template <class t_TYPE>
5583struct UsesBslmaAllocator<bslstl::Optional_Base<t_TYPE, false> >
5585};
5586
5587template <class t_TYPE>
5588struct UsesBslmaAllocator<bsl::optional<t_TYPE> >
5589: UsesBslmaAllocator<t_TYPE> {
5590};
5591
5592} // close namespace bslma
5593
5594
5595namespace bsl {
5596
5597// ============================================================================
5598// Section: CTAD Constructors
5599// ============================================================================
5600
5601# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
5602// CLASS TEMPLATE DEDUCTION GUIDES
5603
5604/// Deduce the specified type `t_TYPE` from the corresponding type supplied
5605/// to the constructor of `optional`.
5606template <class t_TYPE>
5607optional(t_TYPE) -> optional<t_TYPE>;
5608
5609/// Deduce the specified type `t_TYPE` from the corresponding type supplied
5610/// to the constructor of `optional`. This guide does not participate in
5611/// deduction unless the deduced type `t_TYPE` supports the bslma allocator
5612/// model, and the specified `t_ALLOC` can be implicitly converted to
5613/// `bsl::allocator<char>`.
5614template <class t_TYPE,
5615 class t_ALLOC,
5616 class = typename bsl::enable_if_t<
5617 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>,
5618 class = typename bsl::enable_if_t<
5619 bsl::is_convertible_v<t_ALLOC, bsl::allocator<char>>>
5620 >
5621optional(bsl::allocator_arg_t, t_ALLOC, t_TYPE)
5622-> optional<t_TYPE>;
5623
5624/// Deduce the specified type `t_TYPE` from the corresponding template
5625/// parameter type supplied to the constructor of `optional`. This guide
5626/// does not participate in deduction unless the deduced type `t_TYPE`
5627/// supports the bslma allocator model, and the specified `t_ALLOC` can be
5628/// implicitly converted to `bsl::allocator<char>`.
5629template <class t_TYPE,
5630 class t_ALLOC,
5631 class = typename bsl::enable_if_t<
5632 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>,
5633 class = typename bsl::enable_if_t<
5634 bsl::is_convertible_v<t_ALLOC, bsl::allocator<char>>>
5635 >
5636optional(bsl::allocator_arg_t, t_ALLOC, optional<t_TYPE>)
5637-> optional<t_TYPE>;
5638# endif // BSLS_COMPILERFEATURES_SUPPORT_CTAD
5639
5640// ============================================================================
5641// Section: Free Function Declarations
5642// ============================================================================
5643
5644// FREE FUNCTIONS
5645
5646/// Efficiently exchange the values of the specified `lhs` and `rhs`
5647/// objects. This method provides the no-throw exception-safety guarantee
5648/// if the template parameter `t_TYPE` provides that guarantee, `lhs` and
5649/// `rhs` have equal allocators, and `lhs.hasValue() == rhs.hasValue()`.
5650template <class t_TYPE>
5652 void>::type
5654
5655/// Efficiently exchange the values of the specified `lhs` and `rhs`
5656/// objects. This method provides the no-throw exception-safety guarantee
5657/// if the template parameter `t_TYPE` provides that guarantee and the
5658/// result of the `hasValue` method for `lhs` and `rhs` is the same.
5659template <class t_TYPE>
5662 void>::type
5664
5665// HASH SPECIALIZATIONS
5666
5667/// Pass the specified `input` to the specified `hashAlg`, where `hashAlg`
5668/// is a hashing algorithm.
5669template <class t_HASHALG, class t_TYPE>
5670void hashAppend(t_HASHALG& hashAlg, const optional<t_TYPE>& input);
5671
5672// FREE OPERATORS
5673
5674/// Return `true` if the specified `lhs` and `rhs` `optional` objects have the
5675/// same value, and `false` otherwise. Two `optional` objects have the same
5676/// value if both are disengaged, or if both are engaged and the values of
5677/// their underlying objects compare equal. This function can be called in
5678/// constant expressions only if neither `t_LHS_TYPE` nor `t_RHS_TYPE` is
5679/// allocator-aware.
5680template <class t_LHS_TYPE, class t_RHS_TYPE>
5684 BSLSTL_OPTIONAL_REQUIRES(requires {
5685 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5686 });
5687
5688/// Return `true` if the specified `lhs` and `rhs` `optional` objects do not
5689/// have the same value, and `false` otherwise. Two `optional` objects do
5690/// not have the same value if one is disengaged and the other is engaged,
5691/// or if both are engaged and the values of their underlying objects do not
5692/// compare equal. This function can be called in constant expressions only if
5693/// neither `t_LHS_TYPE` nor `t_RHS_TYPE` is allocator-aware.
5694template <class t_LHS_TYPE, class t_RHS_TYPE>
5698 BSLSTL_OPTIONAL_REQUIRES(requires {
5699 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5700 });
5701
5702/// Return `true` if the specified `lhs` `optional` object is ordered before
5703/// the specified `rhs` `optional` object, and `false` otherwise. `lhs` is
5704/// ordered before `rhs` if `lhs` is disengaged and `rhs` is engaged or if
5705/// both are engaged and `lhs.value()` is ordered before `rhs.value()`. This
5706/// function can be called in constant expressions only if neither `t_LHS_TYPE`
5707/// nor `t_RHS_TYPE` is allocator-aware.
5708template <class t_LHS_TYPE, class t_RHS_TYPE>
5712 BSLSTL_OPTIONAL_REQUIRES(requires {
5713 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5714 });
5715
5716/// Return `true` if the specified `lhs` `optional` object is ordered after
5717/// the specified `rhs` `optional` object, and `false` otherwise. `lhs` is
5718/// ordered after `rhs` if `lhs` is engaged and `rhs` is disengaged or if
5719/// both are engaged and `lhs.value()` is ordered after `rhs.value()`. This
5720/// function can be called in constant expressions only if neither `t_LHS_TYPE`
5721/// nor `t_RHS_TYPE` is allocator-aware.
5722template <class t_LHS_TYPE, class t_RHS_TYPE>
5726 BSLSTL_OPTIONAL_REQUIRES(requires {
5727 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5728 });
5729
5730/// Return `true` if the specified `lhs` `optional` object is ordered before
5731/// the specified `rhs` `optional` object or if `lhs` and `rhs` have the
5732/// same value, and `false` otherwise. (See `operator<` and `operator==`.)
5733/// This function can be called in constant expressions only if neither
5734/// `t_LHS_TYPE` nor `t_RHS_TYPE` is allocator-aware.
5735template <class t_LHS_TYPE, class t_RHS_TYPE>
5739 BSLSTL_OPTIONAL_REQUIRES(requires {
5740 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5741 });
5742
5743/// Return `true` if the specified `lhs` `optional` object is ordered after
5744/// the specified `rhs` `optional` object or if `lhs` and `rhs` have the
5745/// same value, and `false` otherwise. (See `operator>` and `operator==`.)
5746/// This function can be called in constant expressions only if neither
5747/// `t_LHS_TYPE` nor `t_RHS_TYPE` is allocator-aware.
5748template <class t_LHS_TYPE, class t_RHS_TYPE>
5752 BSLSTL_OPTIONAL_REQUIRES(requires {
5753 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5754 });
5755
5756// comparison with 'nullopt_t'
5757
5758/// Return `true` if the specified `value` is disengaged, and `false`
5759/// otherwise. This function can be called in constant expressions only if
5760/// `t_TYPE` is not allocator-aware.
5761template <class t_TYPE>
5763bool operator==(const bsl::optional<t_TYPE>& value,
5765#if !(defined(BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON) && \
5766 defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS))
5767template <class t_TYPE>
5769bool operator==(const bsl::nullopt_t&,
5771
5772/// Return `true` if the specified `value` is engaged, and `false` otherwise.
5773/// These functions can be called in constant expressions only if `t_TYPE` is
5774/// not allocator-aware.
5775template <class t_TYPE>
5777bool operator!=(const bsl::optional<t_TYPE>& value,
5779template <class t_TYPE>
5781bool operator!=(const bsl::nullopt_t&,
5783
5784/// Return `false`.
5785/// \note Note that `bsl::nullopt_t` never orders after a
5786/// `bsl::optional`. This function can be called in constant expressions only
5787/// if `t_TYPE` is not allocator-aware.
5788template <class t_TYPE>
5792
5793/// Return `true` if the specified `value` is engaged, and `false` otherwise.
5794///
5795/// \note Note that `bsl::nullopt_t` is ordered before any `bsl::optional` that is
5796/// engaged. This function can be called in constant expressions only if
5797/// `t_TYPE` is not allocator-aware.
5798template <class t_TYPE>
5800bool operator<(const bsl::nullopt_t&,
5802
5803/// Return `true` if the specified `value` is engaged, and `false` otherwise.
5804/// This function can be called in constant expressions only if `t_TYPE` is not
5805/// allocator-aware.
5806template <class t_TYPE>
5808bool operator>(const bsl::optional<t_TYPE>& value,
5810
5811/// Return `false`.
5812/// \note Note that `bsl::nullopt_t` never orders after a
5813/// `bsl::optional`. This function can be called in constant expressions only
5814/// if `t_TYPE` is not allocator-aware.
5815template <class t_TYPE>
5817bool operator>(const bsl::nullopt_t&,
5819
5820/// Return `true` if the specified `value` is disengaged, and `false`
5821/// otherwise. This function can be called in constant expressions only if
5822/// `t_TYPE` is not allocator-aware.
5823template <class t_TYPE>
5825bool operator<=(const bsl::optional<t_TYPE>& value,
5827
5828/// Return `true`.
5829/// \note Note that `bsl::nullopt_t` is ordered before any
5830/// `bsl::optional` that is engaged. This function can be called in constant
5831/// expressions only if `t_TYPE` is not allocator-aware.
5832template <class t_TYPE>
5834bool operator<=(const bsl::nullopt_t&,
5836
5837/// Return `true`.
5838/// \note Note that `bsl::nullopt_t` is ordered before any
5839/// `bsl::optional` that is engaged. This function can be called in constant
5840/// expressions only if `t_TYPE` is not allocator-aware.
5841template <class t_TYPE>
5845
5846/// Return `true` if the specified `value` is disengaged, and `false`
5847/// otherwise. This function can be called in constant expressions only if
5848/// `t_TYPE` is not allocator-aware.
5849template <class t_TYPE>
5851bool operator>=(const bsl::nullopt_t&,
5853#endif // !(defined(BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON) &&
5854 // defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS))
5855
5856// comparison with 'value_type'
5857
5858/// Return `true` if the specified `lhs` and `rhs` objects have the same
5859/// value, and `false` otherwise. An `optional` object and a value of some
5860/// type have the same value if the optional object is engaged and its
5861/// underlying value compares equal to the other value. These functions can be
5862/// called in constant expressions only if the `optional`'s value type is not
5863/// allocator-aware.
5864template <class t_LHS_TYPE, class t_RHS_TYPE>
5867 const t_RHS_TYPE& rhs)
5869 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5870 && requires {
5871 { *lhs == rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5872 });
5873template <class t_LHS_TYPE, class t_RHS_TYPE>
5875bool operator==(const t_LHS_TYPE& lhs,
5878 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
5879 && requires {
5880 { lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5881 });
5882
5883/// Return `true` if the specified `lhs` and `rhs` objects do not have the same
5884/// value, and `false` otherwise. An `optional` object and a value of some
5885/// type do not have the same value if either the optional object is
5886/// disengaged, or its underlying value does not compare equal to the other
5887/// value. These function can be called in constant expressions only if the
5888/// `optional`'s value type is not allocator-aware.
5889template <class t_LHS_TYPE, class t_RHS_TYPE>
5892 const t_RHS_TYPE& rhs)
5894 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5895 && requires {
5896 { *lhs != rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5897 });
5898template <class t_LHS_TYPE, class t_RHS_TYPE>
5900bool operator!=(const t_LHS_TYPE& lhs,
5903 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
5904 && requires {
5905 { lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5906 });
5907
5908/// Return `true` if the specified `lhs` `optional` object is ordered before
5909/// the specified `rhs`, and `false` otherwise. `lhs` is ordered before
5910/// `rhs` if `lhs` is disengaged or `lhs.value()` is ordered before `rhs`.
5911/// This function can be called in constant expressions only if `t_LHS_TYPE`
5912/// is not allocator-aware.
5913template <class t_LHS_TYPE, class t_RHS_TYPE>
5915bool operator<(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
5917 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5918 && requires {
5919 { *lhs < rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5920 });
5921
5922/// Return `true` if the specified `lhs` is ordered before the specified `rhs`
5923/// `optional` object, and `false` otherwise. `lhs` is ordered before `rhs` if
5924/// `rhs` is engaged and `lhs` is ordered before `rhs.value()`. This function
5925/// can be called in constant expressions only if `t_RHS_TYPE` is not
5926/// allocator-aware.
5927template <class t_LHS_TYPE, class t_RHS_TYPE>
5929bool operator<(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
5931 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
5932 && requires {
5933 { lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5934 });
5935
5936/// Return `true` if the specified `lhs` `optional` object is ordered after the
5937/// specified `rhs`, and `false` otherwise. `lhs` is ordered after `rhs` if
5938/// `lhs` is engaged and `lhs.value()` is ordered after `rhs`. This function
5939/// can be called in constant expressions only if `t_LHS_TYPE` is not
5940/// allocator-aware.
5941template <class t_LHS_TYPE, class t_RHS_TYPE>
5943bool operator>(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
5945 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5946 && requires {
5947 { *lhs > rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5948 });
5949
5950/// Return `true` if the specified `lhs` is ordered after the specified `rhs`
5951/// `optional` object, and `false` otherwise. `lhs` is ordered after `rhs` if
5952/// `rhs` is disengaged or `lhs` is ordered after `rhs.value()`. This
5953/// function can be called in constant expressions only if `t_RHS_TYPE` is not
5954/// allocator-aware.
5955template <class t_LHS_TYPE, class t_RHS_TYPE>
5957bool operator>(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
5959 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
5960 && requires {
5961 { lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5962 });
5963
5964/// Return `true` if the specified `lhs` `optional` object is ordered before
5965/// the specified `rhs` or `lhs` and `rhs` have the same value, and `false`
5966/// otherwise. (See `operator<` and `operator==`.) This function can be
5967/// called in constant expressions only if `t_LHS_TYPE` is not allocator-aware.
5968template <class t_LHS_TYPE, class t_RHS_TYPE>
5970bool operator<=(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
5972 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5973 && requires {
5974 { *lhs <= rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5975 });
5976
5977/// Return `true` if the specified `lhs` is ordered before the specified `rhs`
5978/// `optional` object or `lhs` and `rhs` have the same value, and `false`
5979/// otherwise. (See `operator<` and `operator==`.) This function can be
5980/// called in constant expressions only if `t_RHS_TYPE` is not allocator-aware.
5981template <class t_LHS_TYPE, class t_RHS_TYPE>
5983bool operator<=(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
5985 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
5986 && requires {
5987 { lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5988 });
5989
5990/// Return `true` if the specified `lhs` `optional` object is ordered after the
5991/// specified `rhs` or if `lhs` and `rhs` have the same value, and `false`
5992/// otherwise. (See `operator>` and `operator==`.) This function can be
5993/// called in constant expressions only if `t_LHS_TYPE` is not allocator-aware.
5994template <class t_LHS_TYPE, class t_RHS_TYPE>
5996bool operator>=(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
5998 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
5999 && requires {
6000 { *lhs >= rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6001 });
6002
6003// Return `true` if the specified `lhs` is ordered after the specified `rhs`
6004// `optional` object or if `lhs` and `rhs` have the same value, or `false`
6005// otherwise. (See `operator>` and `operator==`.) This function can be
6006/// called in constant expressions only if `t_LHS_TYPE` is not allocator-aware.
6007template <class t_LHS_TYPE, class t_RHS_TYPE>
6009bool operator>=(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
6011 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6012 && requires {
6013 { lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6014 });
6015
6016#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
6017 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
6018/// Perform a three-way comparison of the specified `lhs` and the specified
6019/// `rhs` objects by using the comparison operators of `t_LHS` and `t_RHS`;
6020/// return the result of that comparison. This function can be called in
6021/// constant expressions only if neither `t_LHS` nor `t_RHS` is
6022/// allocator-aware.
6023template <class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
6025compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6027 const bsl::optional<t_RHS>& rhs);
6028
6029/// Perform a three-way comparison of the specified `lhs` and the specified
6030/// `rhs` objects by using the comparison operators of `t_LHS` and `t_RHS`;
6031/// return the result of that comparison. This function can be called in
6032/// constant expressions only if `t_LHS` is not allocator-aware.
6033template <class t_LHS, class t_RHS>
6034requires (!BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS>) &&
6035 three_way_comparable_with<t_LHS, t_RHS>
6037compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6039 const t_RHS& rhs);
6040
6041/// Perform a three-way comparison of the specified `value` and `nullopt`;
6042/// return the result of that comparison. This function can be called in
6043/// constant expressions only if `t_TYPE` is not allocator-aware.
6044template <class t_TYPE>
6046strong_ordering operator<=>(const bsl::optional<t_TYPE>& value,
6048
6049/// Perform a three-way comparison of the specified `lhs` and the specified
6050/// `rhs` objects by using the comparison operators of `t_LHS` and `t_RHS`;
6051/// return the result of that comparison. This function can be called in
6052/// constant expressions only if `t_LHS` is not allocator-aware.
6053template <class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
6055compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6057 const std::optional<t_RHS>& rhs);
6058#endif
6059
6060# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
6061/// Efficiently exchange the values of the specified `lhs` and `rhs`
6062/// objects. This method provides the no-throw exception-safety guarantee
6063/// if the template parameter `t_TYPE` provides that guarantee and the
6064/// result of the `hasValue` method for `lhs` and `rhs` is the same. This
6065/// function can be called in constant expressions only if `t_TYPE` is not
6066/// allocator-aware.
6067template <class t_TYPE>
6069 void>::type
6070swap(bsl::optional<t_TYPE>& lhs, std::optional<t_TYPE>& rhs);
6071template <class t_TYPE>
6074 void>::type
6075swap(std::optional<t_TYPE>& lhs, bsl::optional<t_TYPE>& rhs);
6076
6077// comparison with 'std::optional'
6078
6079/// Return `true` if the specified `lhs` and `rhs` optional objects have the
6080/// same value, and `false` otherwise. Two optional objects have the same
6081/// value if both are disengaged, or if both are engaged and the values of their underlying objects compare equal.
6082///
6083/// \note Note that this function will
6084/// fail to compile if `t_LHS_TYPE` and `t_RHS_TYPE` are not compatible.
6085/// These functions can be called in constant expressions only if the
6086/// `bsl::optional`'s value type is not allocator-aware.
6087template <class t_LHS_TYPE, class t_RHS_TYPE>
6088constexpr bool operator==(const std::optional<t_LHS_TYPE>& lhs,
6090 BSLSTL_OPTIONAL_REQUIRES(requires {
6091 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6092 });
6093template <class t_LHS_TYPE, class t_RHS_TYPE>
6094constexpr bool operator==(const bsl::optional<t_LHS_TYPE>& lhs,
6095 const std::optional<t_RHS_TYPE>& rhs)
6096 BSLSTL_OPTIONAL_REQUIRES(requires {
6097 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6098 });
6099
6100/// Return `true` if the specified `lhs` and `rhs` optional objects do not
6101/// have the same value, and `false` otherwise. Two optional objects do not
6102/// have the same value if one is disengaged and the other is engaged, or if
6103/// both are engaged and the values of their underlying objects do not compare equal.
6104///
6105/// \note Note that this function will fail to compile if
6106/// `t_LHS_TYPE` and `t_RHS_TYPE` are not compatible. These functions can be
6107/// called in constant expressions only if the `bsl::optional`'s value type is
6108/// not allocator-aware.
6109template <class t_LHS_TYPE, class t_RHS_TYPE>
6110constexpr bool operator!=(const bsl::optional<t_LHS_TYPE>& lhs,
6111 const std::optional<t_RHS_TYPE>& rhs)
6112 BSLSTL_OPTIONAL_REQUIRES(requires {
6113 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6114 });
6115template <class t_LHS_TYPE, class t_RHS_TYPE>
6116constexpr bool operator!=(const std::optional<t_LHS_TYPE>& lhs,
6118 BSLSTL_OPTIONAL_REQUIRES(requires {
6119 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6120 });
6121
6122/// Return `true` if the specified `lhs` optional object is ordered before
6123/// the specified `rhs` optional object, and `false` otherwise. `lhs` is
6124/// ordered before `rhs` if `lhs` is disengaged and `rhs` is engaged or if
6125/// both are engaged and `lhs.value()` is ordered before `rhs.value()`.
6126///
6127/// \note Note that this function will fail to compile if `t_LHS_TYPE` and
6128/// `t_RHS_TYPE` are not compatible. These functions can be called in
6129/// constant expressions only if the `bsl::optional`'s value type is not
6130/// allocator-aware.
6131template <class t_LHS_TYPE, class t_RHS_TYPE>
6132constexpr bool operator<(const bsl::optional<t_LHS_TYPE>& lhs,
6133 const std::optional<t_RHS_TYPE>& rhs)
6134 BSLSTL_OPTIONAL_REQUIRES(requires {
6135 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6136 });
6137template <class t_LHS_TYPE, class t_RHS_TYPE>
6138constexpr bool operator<(const std::optional<t_LHS_TYPE>& lhs,
6140 BSLSTL_OPTIONAL_REQUIRES(requires {
6141 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6142 });
6143
6144/// Return `true` if the specified `lhs` optional object is ordered after
6145/// the specified `rhs` optional object, and `false` otherwise. `lhs` is
6146/// ordered after `rhs` if `lhs` is engaged and `rhs` is disengaged or if
6147/// both are engaged and `lhs.value()` is ordered after `rhs.value()`.
6148///
6149/// \note Note that this function will fail to compile if `t_LHS_TYPE` and `t_RHS_TYPE`
6150/// are not compatible. These functions can be called in constant expressions
6151/// only if the `bsl::optional`'s value type is not allocator-aware.
6152template <class t_LHS_TYPE, class t_RHS_TYPE>
6153constexpr bool operator>(const bsl::optional<t_LHS_TYPE>& lhs,
6154 const std::optional<t_RHS_TYPE>& rhs)
6155 BSLSTL_OPTIONAL_REQUIRES(requires {
6156 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6157 });
6158template <class t_LHS_TYPE, class t_RHS_TYPE>
6159constexpr bool operator>(const std::optional<t_LHS_TYPE>& lhs,
6161 BSLSTL_OPTIONAL_REQUIRES(requires {
6162 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6163 });
6164
6165/// Return `true` if the specified `lhs` is ordered before the specified
6166/// `rhs` optional object or `lhs` and `rhs` have the same value, and `false` otherwise. (See `operator<` and `operator==`.)
6167///
6168/// \note Note that this
6169/// function will fail to compile if `t_LHS_TYPE` and `t_RHS_TYPE` are not
6170/// compatible. These functions can be called in constant expressions only if
6171/// the `bsl::optional`'s value type is not allocator-aware.
6172template <class t_LHS_TYPE, class t_RHS_TYPE>
6173constexpr bool operator<=(const bsl::optional<t_LHS_TYPE>& lhs,
6174 const std::optional<t_RHS_TYPE>& rhs)
6175 BSLSTL_OPTIONAL_REQUIRES(requires {
6176 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6177 });
6178template <class t_LHS_TYPE, class t_RHS_TYPE>
6179constexpr bool operator<=(const std::optional<t_LHS_TYPE>& lhs,
6181 BSLSTL_OPTIONAL_REQUIRES(requires {
6182 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6183 });
6184
6185/// Return `true` if the specified `lhs` optional object is ordered after
6186/// the specified `rhs` optional object or `lhs` and `rhs` have the same
6187/// value, and `false` otherwise. (See `operator>` and `operator==`.)
6188///
6189/// \note Note that this function will fail to compile if `t_LHS_TYPE` and `t_RHS_TYPE`
6190/// are not compatible. These functions can be called in constant expressions
6191/// only if the `bsl::optional`'s value type is not allocator-aware.
6192template <class t_LHS_TYPE, class t_RHS_TYPE>
6193constexpr bool operator>=(const bsl::optional<t_LHS_TYPE>& lhs,
6194 const std::optional<t_RHS_TYPE>& rhs)
6195 BSLSTL_OPTIONAL_REQUIRES(requires {
6196 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6197 });
6198template <class t_LHS_TYPE, class t_RHS_TYPE>
6199constexpr bool operator>=(const std::optional<t_LHS_TYPE>& lhs,
6201 BSLSTL_OPTIONAL_REQUIRES(requires {
6202 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6203 });
6204#endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
6205
6206/// Return an `optional` object containing a `t_TYPE` object created by
6207/// invoking a `bsl::optional` allocator-extended `in_place_t` constructor
6208/// with the specified `alloc` as the allocator argument, and specified `rhs` as the constructor argument.
6209///
6210/// \note Note that this function will fail to
6211/// compile if `t_TYPE` doesn't use allocators.
6212template <class t_TYPE>
6215 const typename bsl::optional<
6216 typename bsl::decay<t_TYPE>::type>::allocator_type& alloc,
6218
6219#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
6220// {{{ BEGIN GENERATED CODE
6221// Command line: sim_cpp11_features.pl bslstl_optional.h
6222#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
6223#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
6224#endif
6225#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_J
6226#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_J BSLSTL_OPTIONAL_VARIADIC_LIMIT
6227#endif
6228#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 0
6229template <class t_TYPE>
6232 typename bsl::optional<t_TYPE>::allocator_type const& alloc);
6233#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 0
6234
6235#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 1
6236template <class t_TYPE, class t_ARGS_01>
6239 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
6241#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 1
6242
6243#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 2
6244template <class t_TYPE, class t_ARGS_01,
6245 class t_ARGS_02>
6248 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6249 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6250 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
6251#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 2
6252
6253#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 3
6254template <class t_TYPE, class t_ARGS_01,
6255 class t_ARGS_02,
6256 class t_ARGS_03>
6259 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6260 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6261 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6262 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
6263#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 3
6264
6265#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 4
6266template <class t_TYPE, class t_ARGS_01,
6267 class t_ARGS_02,
6268 class t_ARGS_03,
6269 class t_ARGS_04>
6272 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6273 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6274 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6275 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6276 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
6277#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 4
6278
6279#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 5
6280template <class t_TYPE, class t_ARGS_01,
6281 class t_ARGS_02,
6282 class t_ARGS_03,
6283 class t_ARGS_04,
6284 class t_ARGS_05>
6287 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6288 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6289 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6290 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6291 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6292 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
6293#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 5
6294
6295#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 6
6296template <class t_TYPE, class t_ARGS_01,
6297 class t_ARGS_02,
6298 class t_ARGS_03,
6299 class t_ARGS_04,
6300 class t_ARGS_05,
6301 class t_ARGS_06>
6304 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6305 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6306 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6308 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6309 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6310 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
6311#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 6
6312
6313#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 7
6314template <class t_TYPE, class t_ARGS_01,
6315 class t_ARGS_02,
6316 class t_ARGS_03,
6317 class t_ARGS_04,
6318 class t_ARGS_05,
6319 class t_ARGS_06,
6320 class t_ARGS_07>
6323 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6324 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6325 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6326 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6327 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6328 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6329 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6330 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
6331#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 7
6332
6333#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 8
6334template <class t_TYPE, class t_ARGS_01,
6335 class t_ARGS_02,
6336 class t_ARGS_03,
6337 class t_ARGS_04,
6338 class t_ARGS_05,
6339 class t_ARGS_06,
6340 class t_ARGS_07,
6341 class t_ARGS_08>
6344 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6345 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6346 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
6353#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 8
6354
6355#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 9
6356template <class t_TYPE, class t_ARGS_01,
6357 class t_ARGS_02,
6358 class t_ARGS_03,
6359 class t_ARGS_04,
6360 class t_ARGS_05,
6361 class t_ARGS_06,
6362 class t_ARGS_07,
6363 class t_ARGS_08,
6364 class t_ARGS_09>
6367 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6368 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6369 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6370 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6371 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6372 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6373 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6374 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6375 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6376 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
6377#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 9
6378
6379#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 10
6380template <class t_TYPE, class t_ARGS_01,
6381 class t_ARGS_02,
6382 class t_ARGS_03,
6383 class t_ARGS_04,
6384 class t_ARGS_05,
6385 class t_ARGS_06,
6386 class t_ARGS_07,
6387 class t_ARGS_08,
6388 class t_ARGS_09,
6389 class t_ARGS_10>
6392 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6393 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6394 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6395 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6396 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6397 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6398 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6399 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6400 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6401 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
6402 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
6403#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 10
6404
6405
6406# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6407#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 0
6408template <class t_TYPE, class t_INIT_LIST_TYPE>
6411 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6412 std::initializer_list<t_INIT_LIST_TYPE> il);
6413#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 0
6414
6415#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 1
6416template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01>
6419 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6420 std::initializer_list<t_INIT_LIST_TYPE> il,
6421 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
6422#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 1
6423
6424#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 2
6425template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6426 class t_ARGS_02>
6429 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6430 std::initializer_list<t_INIT_LIST_TYPE> il,
6431 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6432 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
6433#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 2
6434
6435#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 3
6436template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6437 class t_ARGS_02,
6438 class t_ARGS_03>
6441 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6442 std::initializer_list<t_INIT_LIST_TYPE> il,
6443 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6444 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6445 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
6446#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 3
6447
6448#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 4
6449template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6450 class t_ARGS_02,
6451 class t_ARGS_03,
6452 class t_ARGS_04>
6455 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6456 std::initializer_list<t_INIT_LIST_TYPE> il,
6457 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6458 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6459 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6460 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
6461#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 4
6462
6463#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 5
6464template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6465 class t_ARGS_02,
6466 class t_ARGS_03,
6467 class t_ARGS_04,
6468 class t_ARGS_05>
6471 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6472 std::initializer_list<t_INIT_LIST_TYPE> il,
6473 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6474 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6475 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6476 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6477 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
6478#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 5
6479
6480#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 6
6481template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6482 class t_ARGS_02,
6483 class t_ARGS_03,
6484 class t_ARGS_04,
6485 class t_ARGS_05,
6486 class t_ARGS_06>
6489 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6490 std::initializer_list<t_INIT_LIST_TYPE> il,
6491 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6492 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6493 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6494 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6495 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6496 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
6497#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 6
6498
6499#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 7
6500template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6501 class t_ARGS_02,
6502 class t_ARGS_03,
6503 class t_ARGS_04,
6504 class t_ARGS_05,
6505 class t_ARGS_06,
6506 class t_ARGS_07>
6509 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6510 std::initializer_list<t_INIT_LIST_TYPE> il,
6511 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6512 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6513 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6514 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6515 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6516 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6517 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
6518#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 7
6519
6520#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 8
6521template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6522 class t_ARGS_02,
6523 class t_ARGS_03,
6524 class t_ARGS_04,
6525 class t_ARGS_05,
6526 class t_ARGS_06,
6527 class t_ARGS_07,
6528 class t_ARGS_08>
6531 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6532 std::initializer_list<t_INIT_LIST_TYPE> il,
6533 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6534 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6535 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6536 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6537 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6538 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6539 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6540 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
6541#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 8
6542
6543#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 9
6544template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6545 class t_ARGS_02,
6546 class t_ARGS_03,
6547 class t_ARGS_04,
6548 class t_ARGS_05,
6549 class t_ARGS_06,
6550 class t_ARGS_07,
6551 class t_ARGS_08,
6552 class t_ARGS_09>
6555 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6556 std::initializer_list<t_INIT_LIST_TYPE> il,
6557 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6558 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6559 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6560 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6561 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6562 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6563 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6564 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6565 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
6566#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 9
6567
6568#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 10
6569template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6570 class t_ARGS_02,
6571 class t_ARGS_03,
6572 class t_ARGS_04,
6573 class t_ARGS_05,
6574 class t_ARGS_06,
6575 class t_ARGS_07,
6576 class t_ARGS_08,
6577 class t_ARGS_09,
6578 class t_ARGS_10>
6581 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6582 std::initializer_list<t_INIT_LIST_TYPE> il,
6583 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6584 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6585 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6586 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6587 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6588 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6589 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6590 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6591 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
6592 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
6593#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_J >= 10
6594
6595# endif
6596#else
6597// The generated code below is a workaround for the absence of perfect
6598// forwarding in some compilers.
6599template <class t_TYPE, class... t_ARGS>
6602 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6603 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
6604
6605# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6606template <class t_TYPE, class t_INIT_LIST_TYPE, class... t_ARGS>
6609 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
6610 std::initializer_list<t_INIT_LIST_TYPE> il,
6611 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
6612# endif
6613// }}} END GENERATED CODE
6614#endif
6615
6616/// Return an `optional` object containing a `t_TYPE` object created by
6617/// invoking a `bsl::optional` constructor with the specified `rhs` as the
6618/// constructor argument. If `t_TYPE` uses an allocator, the default
6619/// allocator will be used for the `optional` object. This function can be
6620/// called in constant expressions only if `t_TYPE` is not allocator-aware.
6621template <class t_TYPE>
6624
6625/// Return an `optional` object containing a value-initialized `t_TYPE`
6626/// object. If `t_TYPE` uses an allocator, the default allocator will be
6627/// used for the `optional` object. This function can be called in constant
6628/// expressions only if `t_TYPE` is not allocator-aware.
6629template <class t_TYPE>
6631
6632#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
6633// {{{ BEGIN GENERATED CODE
6634// Command line: sim_cpp11_features.pl bslstl_optional.h
6635#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
6636#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
6637#endif
6638#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_K
6639#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_K BSLSTL_OPTIONAL_VARIADIC_LIMIT
6640#endif
6641#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 0
6642template <class t_TYPE, class t_ARG>
6645#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 0
6646
6647#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 1
6648template <class t_TYPE, class t_ARG, class t_ARGS_01>
6651 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
6652#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 1
6653
6654#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 2
6655template <class t_TYPE, class t_ARG, class t_ARGS_01,
6656 class t_ARGS_02>
6659 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6660 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
6661#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 2
6662
6663#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 3
6664template <class t_TYPE, class t_ARG, class t_ARGS_01,
6665 class t_ARGS_02,
6666 class t_ARGS_03>
6669 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6670 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6671 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
6672#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 3
6673
6674#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 4
6675template <class t_TYPE, class t_ARG, class t_ARGS_01,
6676 class t_ARGS_02,
6677 class t_ARGS_03,
6678 class t_ARGS_04>
6681 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6682 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6683 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6684 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
6685#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 4
6686
6687#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 5
6688template <class t_TYPE, class t_ARG, class t_ARGS_01,
6689 class t_ARGS_02,
6690 class t_ARGS_03,
6691 class t_ARGS_04,
6692 class t_ARGS_05>
6695 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6696 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6697 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6698 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6699 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
6700#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 5
6701
6702#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 6
6703template <class t_TYPE, class t_ARG, class t_ARGS_01,
6704 class t_ARGS_02,
6705 class t_ARGS_03,
6706 class t_ARGS_04,
6707 class t_ARGS_05,
6708 class t_ARGS_06>
6711 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6712 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6713 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6714 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6715 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6716 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
6717#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 6
6718
6719#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 7
6720template <class t_TYPE, class t_ARG, class t_ARGS_01,
6721 class t_ARGS_02,
6722 class t_ARGS_03,
6723 class t_ARGS_04,
6724 class t_ARGS_05,
6725 class t_ARGS_06,
6726 class t_ARGS_07>
6729 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6730 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6731 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6732 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6733 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6734 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6735 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
6736#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 7
6737
6738#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 8
6739template <class t_TYPE, class t_ARG, class t_ARGS_01,
6740 class t_ARGS_02,
6741 class t_ARGS_03,
6742 class t_ARGS_04,
6743 class t_ARGS_05,
6744 class t_ARGS_06,
6745 class t_ARGS_07,
6746 class t_ARGS_08>
6749 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6750 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6751 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6752 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6753 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6754 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6755 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6756 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
6757#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 8
6758
6759#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 9
6760template <class t_TYPE, class t_ARG, class t_ARGS_01,
6761 class t_ARGS_02,
6762 class t_ARGS_03,
6763 class t_ARGS_04,
6764 class t_ARGS_05,
6765 class t_ARGS_06,
6766 class t_ARGS_07,
6767 class t_ARGS_08,
6768 class t_ARGS_09>
6771 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6773 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6774 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6775 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6776 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6777 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6778 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6779 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
6780#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 9
6781
6782#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 10
6783template <class t_TYPE, class t_ARG, class t_ARGS_01,
6784 class t_ARGS_02,
6785 class t_ARGS_03,
6786 class t_ARGS_04,
6787 class t_ARGS_05,
6788 class t_ARGS_06,
6789 class t_ARGS_07,
6790 class t_ARGS_08,
6791 class t_ARGS_09,
6792 class t_ARGS_10>
6795 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6796 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6797 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6798 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6799 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6800 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6801 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6802 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6803 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
6804 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
6805#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 10
6806
6807
6808# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6809#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 0
6810template <class t_TYPE, class t_INIT_LIST_TYPE>
6812make_optional(std::initializer_list<t_INIT_LIST_TYPE> il);
6813#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 0
6814
6815#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 1
6816template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01>
6818make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01);
6820#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 1
6821
6822#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 2
6823template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6824 class t_ARGS_02>
6826make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6827 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6828 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02);
6829#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 2
6830
6831#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 3
6832template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6833 class t_ARGS_02,
6834 class t_ARGS_03>
6836make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6837 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6838 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6839 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03);
6840#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 3
6841
6842#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 4
6843template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6844 class t_ARGS_02,
6845 class t_ARGS_03,
6846 class t_ARGS_04>
6848make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6849 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6850 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6851 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6852 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04);
6853#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 4
6854
6855#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 5
6856template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6857 class t_ARGS_02,
6858 class t_ARGS_03,
6859 class t_ARGS_04,
6860 class t_ARGS_05>
6862make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6863 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6864 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6865 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6866 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6867 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05);
6868#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 5
6869
6870#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 6
6871template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6872 class t_ARGS_02,
6873 class t_ARGS_03,
6874 class t_ARGS_04,
6875 class t_ARGS_05,
6876 class t_ARGS_06>
6878make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6879 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6880 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6881 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6882 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6883 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6884 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06);
6885#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 6
6886
6887#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 7
6888template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6889 class t_ARGS_02,
6890 class t_ARGS_03,
6891 class t_ARGS_04,
6892 class t_ARGS_05,
6893 class t_ARGS_06,
6894 class t_ARGS_07>
6896make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6897 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6898 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6899 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6900 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6901 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6902 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6903 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07);
6904#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 7
6905
6906#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 8
6907template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6908 class t_ARGS_02,
6909 class t_ARGS_03,
6910 class t_ARGS_04,
6911 class t_ARGS_05,
6912 class t_ARGS_06,
6913 class t_ARGS_07,
6914 class t_ARGS_08>
6916make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6917 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6918 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6919 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6920 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6921 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6922 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6923 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6924 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08);
6925#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 8
6926
6927#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 9
6928template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6929 class t_ARGS_02,
6930 class t_ARGS_03,
6931 class t_ARGS_04,
6932 class t_ARGS_05,
6933 class t_ARGS_06,
6934 class t_ARGS_07,
6935 class t_ARGS_08,
6936 class t_ARGS_09>
6938make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6939 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6940 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6941 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6942 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6943 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6945 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6946 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6947 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09);
6948#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 9
6949
6950#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 10
6951template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
6952 class t_ARGS_02,
6953 class t_ARGS_03,
6954 class t_ARGS_04,
6955 class t_ARGS_05,
6956 class t_ARGS_06,
6957 class t_ARGS_07,
6958 class t_ARGS_08,
6959 class t_ARGS_09,
6960 class t_ARGS_10>
6962make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6963 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
6964 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
6965 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
6966 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
6967 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
6968 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
6969 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
6970 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
6971 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
6972 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10);
6973#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_K >= 10
6974
6975
6976# endif
6977#else
6978// The generated code below is a workaround for the absence of perfect
6979// forwarding in some compilers.
6980template <class t_TYPE, class t_ARG, class... t_ARGS>
6983 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
6984
6985# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6986template <class t_TYPE, class t_INIT_LIST_TYPE, class... t_ARGS>
6988make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
6989 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args);
6990
6991# endif
6992// }}} END GENERATED CODE
6993#endif
6994
6995} // close namespace bsl
6996
6997// ============================================================================
6998// INLINE DEFINITIONS
6999// ============================================================================
7000
7001
7002namespace bslstl {
7003
7004// ============================================================================
7005// Section: bslstl::Optional_* Definitions
7006// ============================================================================
7007
7008 // ======================
7009 // class Optional_DataImp
7010 // ======================
7011
7012// CREATORS
7013template <class t_TYPE>
7015: d_hasValue(false)
7016{
7017}
7018
7019#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
7020template <class t_TYPE>
7021template <class t_INVOCABLE, class t_ARG>
7022inline
7024 Optional_InvokeConstructorTag ,
7025 t_INVOCABLE&& invocable,
7026 t_ARG&& arg)
7027: d_hasValue(false)
7028{
7029 // Direct non-list initialization is mandated here
7030 ::new((void*)d_buffer.address()) t_TYPE(
7031 std::invoke(std::forward<t_INVOCABLE>(invocable),
7032 std::forward<t_ARG>(arg)));
7033 d_hasValue = true;
7034}
7035#endif
7036
7037// MANIPULATORS
7038#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
7039// {{{ BEGIN GENERATED CODE
7040// Command line: sim_cpp11_features.pl bslstl_optional.h
7041#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
7042#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
7043#endif
7044#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_L
7045#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_L BSLSTL_OPTIONAL_VARIADIC_LIMIT
7046#endif
7047#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 0
7048template <class t_TYPE>
7049inline
7050t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7051 bslma::Allocator *allocator)
7052{
7053 reset();
7054 BloombergLP::bslma::ConstructionUtil::construct(
7055 d_buffer.address(),
7056 allocator);
7057 d_hasValue = true;
7058 return d_buffer.object();
7059}
7060#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 0
7061
7062#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 1
7063template <class t_TYPE>
7064template <class t_ARGS_01>
7065inline
7066t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7067 bslma::Allocator *allocator,
7068 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
7069{
7070 reset();
7071 BloombergLP::bslma::ConstructionUtil::construct(
7072 d_buffer.address(),
7073 allocator,
7074 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
7075 d_hasValue = true;
7076 return d_buffer.object();
7077}
7078#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 1
7079
7080#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 2
7081template <class t_TYPE>
7082template <class t_ARGS_01,
7083 class t_ARGS_02>
7084inline
7085t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7086 bslma::Allocator *allocator,
7087 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7088 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
7089{
7090 reset();
7091 BloombergLP::bslma::ConstructionUtil::construct(
7092 d_buffer.address(),
7093 allocator,
7094 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7095 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
7096 d_hasValue = true;
7097 return d_buffer.object();
7098}
7099#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 2
7100
7101#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 3
7102template <class t_TYPE>
7103template <class t_ARGS_01,
7104 class t_ARGS_02,
7105 class t_ARGS_03>
7106inline
7107t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7108 bslma::Allocator *allocator,
7109 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7110 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
7112{
7113 reset();
7114 BloombergLP::bslma::ConstructionUtil::construct(
7115 d_buffer.address(),
7116 allocator,
7117 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7118 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7119 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
7120 d_hasValue = true;
7121 return d_buffer.object();
7122}
7123#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 3
7124
7125#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 4
7126template <class t_TYPE>
7127template <class t_ARGS_01,
7128 class t_ARGS_02,
7129 class t_ARGS_03,
7130 class t_ARGS_04>
7131inline
7132t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7133 bslma::Allocator *allocator,
7134 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7135 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7136 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7137 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
7138{
7139 reset();
7140 BloombergLP::bslma::ConstructionUtil::construct(
7141 d_buffer.address(),
7142 allocator,
7143 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7144 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7145 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7146 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
7147 d_hasValue = true;
7148 return d_buffer.object();
7149}
7150#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 4
7151
7152#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 5
7153template <class t_TYPE>
7154template <class t_ARGS_01,
7155 class t_ARGS_02,
7156 class t_ARGS_03,
7157 class t_ARGS_04,
7158 class t_ARGS_05>
7159inline
7160t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7161 bslma::Allocator *allocator,
7162 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7163 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7164 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7165 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7166 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
7167{
7168 reset();
7169 BloombergLP::bslma::ConstructionUtil::construct(
7170 d_buffer.address(),
7171 allocator,
7172 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7173 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7174 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7175 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7176 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
7177 d_hasValue = true;
7178 return d_buffer.object();
7179}
7180#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 5
7181
7182#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 6
7183template <class t_TYPE>
7184template <class t_ARGS_01,
7185 class t_ARGS_02,
7186 class t_ARGS_03,
7187 class t_ARGS_04,
7188 class t_ARGS_05,
7189 class t_ARGS_06>
7190inline
7191t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7192 bslma::Allocator *allocator,
7193 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7194 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7195 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7196 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7197 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7198 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
7199{
7200 reset();
7201 BloombergLP::bslma::ConstructionUtil::construct(
7202 d_buffer.address(),
7203 allocator,
7204 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7205 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7206 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7207 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7208 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7209 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
7210 d_hasValue = true;
7211 return d_buffer.object();
7212}
7213#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 6
7214
7215#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 7
7216template <class t_TYPE>
7217template <class t_ARGS_01,
7218 class t_ARGS_02,
7219 class t_ARGS_03,
7220 class t_ARGS_04,
7221 class t_ARGS_05,
7222 class t_ARGS_06,
7223 class t_ARGS_07>
7224inline
7225t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7226 bslma::Allocator *allocator,
7227 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7228 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7229 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7230 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7231 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7232 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7233 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
7234{
7235 reset();
7236 BloombergLP::bslma::ConstructionUtil::construct(
7237 d_buffer.address(),
7238 allocator,
7239 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7240 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7241 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7242 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7243 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7244 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7245 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
7246 d_hasValue = true;
7247 return d_buffer.object();
7248}
7249#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 7
7250
7251#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 8
7252template <class t_TYPE>
7253template <class t_ARGS_01,
7254 class t_ARGS_02,
7255 class t_ARGS_03,
7256 class t_ARGS_04,
7257 class t_ARGS_05,
7258 class t_ARGS_06,
7259 class t_ARGS_07,
7260 class t_ARGS_08>
7261inline
7262t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7263 bslma::Allocator *allocator,
7264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7265 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7266 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7267 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7268 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7269 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7270 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7271 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
7272{
7273 reset();
7274 BloombergLP::bslma::ConstructionUtil::construct(
7275 d_buffer.address(),
7276 allocator,
7277 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7278 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7279 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7280 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7281 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7282 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7283 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7284 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
7285 d_hasValue = true;
7286 return d_buffer.object();
7287}
7288#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 8
7289
7290#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 9
7291template <class t_TYPE>
7292template <class t_ARGS_01,
7293 class t_ARGS_02,
7294 class t_ARGS_03,
7295 class t_ARGS_04,
7296 class t_ARGS_05,
7297 class t_ARGS_06,
7298 class t_ARGS_07,
7299 class t_ARGS_08,
7300 class t_ARGS_09>
7301inline
7302t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7303 bslma::Allocator *allocator,
7304 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7305 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7306 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7308 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7309 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7310 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7311 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
7312 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
7313{
7314 reset();
7315 BloombergLP::bslma::ConstructionUtil::construct(
7316 d_buffer.address(),
7317 allocator,
7318 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7319 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7320 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7321 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7322 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7323 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7324 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7325 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
7326 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
7327 d_hasValue = true;
7328 return d_buffer.object();
7329}
7330#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 9
7331
7332#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 10
7333template <class t_TYPE>
7334template <class t_ARGS_01,
7335 class t_ARGS_02,
7336 class t_ARGS_03,
7337 class t_ARGS_04,
7338 class t_ARGS_05,
7339 class t_ARGS_06,
7340 class t_ARGS_07,
7341 class t_ARGS_08,
7342 class t_ARGS_09,
7343 class t_ARGS_10>
7344inline
7345t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7346 bslma::Allocator *allocator,
7347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7353 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
7355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
7356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
7357{
7358 reset();
7359 BloombergLP::bslma::ConstructionUtil::construct(
7360 d_buffer.address(),
7361 allocator,
7362 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7363 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7364 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7365 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7366 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7367 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7368 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7369 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
7370 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
7371 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
7372 d_hasValue = true;
7373 return d_buffer.object();
7374}
7375#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 10
7376
7377
7378# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
7379#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 0
7380template <class t_TYPE>
7381template <class t_INIT_LIST_TYPE>
7382t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7383 bslma::Allocator *allocator,
7384 std::initializer_list<t_INIT_LIST_TYPE> il)
7385{
7386 reset();
7387 BloombergLP::bslma::ConstructionUtil::construct(
7388 d_buffer.address(),
7389 allocator,
7390 il);
7391 d_hasValue = true;
7392 return d_buffer.object();
7393}
7394#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 0
7395
7396#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 1
7397template <class t_TYPE>
7398template <class t_INIT_LIST_TYPE, class t_ARGS_01>
7399t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7400 bslma::Allocator *allocator,
7401 std::initializer_list<t_INIT_LIST_TYPE> il,
7402 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
7403{
7404 reset();
7405 BloombergLP::bslma::ConstructionUtil::construct(
7406 d_buffer.address(),
7407 allocator,
7408 il,
7409 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
7410 d_hasValue = true;
7411 return d_buffer.object();
7412}
7413#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 1
7414
7415#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 2
7416template <class t_TYPE>
7417template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7418 class t_ARGS_02>
7419t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7420 bslma::Allocator *allocator,
7421 std::initializer_list<t_INIT_LIST_TYPE> il,
7422 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7423 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
7424{
7425 reset();
7426 BloombergLP::bslma::ConstructionUtil::construct(
7427 d_buffer.address(),
7428 allocator,
7429 il,
7430 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7431 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
7432 d_hasValue = true;
7433 return d_buffer.object();
7434}
7435#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 2
7436
7437#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 3
7438template <class t_TYPE>
7439template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7440 class t_ARGS_02,
7441 class t_ARGS_03>
7442t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7443 bslma::Allocator *allocator,
7444 std::initializer_list<t_INIT_LIST_TYPE> il,
7445 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7446 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7447 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
7448{
7449 reset();
7450 BloombergLP::bslma::ConstructionUtil::construct(
7451 d_buffer.address(),
7452 allocator,
7453 il,
7454 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7455 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7456 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
7457 d_hasValue = true;
7458 return d_buffer.object();
7459}
7460#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 3
7461
7462#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 4
7463template <class t_TYPE>
7464template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7465 class t_ARGS_02,
7466 class t_ARGS_03,
7467 class t_ARGS_04>
7468t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7469 bslma::Allocator *allocator,
7470 std::initializer_list<t_INIT_LIST_TYPE> il,
7471 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7472 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7473 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7474 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
7475{
7476 reset();
7477 BloombergLP::bslma::ConstructionUtil::construct(
7478 d_buffer.address(),
7479 allocator,
7480 il,
7481 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7482 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7483 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7484 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
7485 d_hasValue = true;
7486 return d_buffer.object();
7487}
7488#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 4
7489
7490#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 5
7491template <class t_TYPE>
7492template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7493 class t_ARGS_02,
7494 class t_ARGS_03,
7495 class t_ARGS_04,
7496 class t_ARGS_05>
7497t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7498 bslma::Allocator *allocator,
7499 std::initializer_list<t_INIT_LIST_TYPE> il,
7500 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7501 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7502 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7503 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7504 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
7505{
7506 reset();
7507 BloombergLP::bslma::ConstructionUtil::construct(
7508 d_buffer.address(),
7509 allocator,
7510 il,
7511 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7512 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7513 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7514 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7515 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
7516 d_hasValue = true;
7517 return d_buffer.object();
7518}
7519#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 5
7520
7521#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 6
7522template <class t_TYPE>
7523template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7524 class t_ARGS_02,
7525 class t_ARGS_03,
7526 class t_ARGS_04,
7527 class t_ARGS_05,
7528 class t_ARGS_06>
7529t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7530 bslma::Allocator *allocator,
7531 std::initializer_list<t_INIT_LIST_TYPE> il,
7532 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7533 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7534 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7535 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7536 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7537 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
7538{
7539 reset();
7540 BloombergLP::bslma::ConstructionUtil::construct(
7541 d_buffer.address(),
7542 allocator,
7543 il,
7544 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7545 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7546 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7547 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7548 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7549 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
7550 d_hasValue = true;
7551 return d_buffer.object();
7552}
7553#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 6
7554
7555#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 7
7556template <class t_TYPE>
7557template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7558 class t_ARGS_02,
7559 class t_ARGS_03,
7560 class t_ARGS_04,
7561 class t_ARGS_05,
7562 class t_ARGS_06,
7563 class t_ARGS_07>
7564t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7565 bslma::Allocator *allocator,
7566 std::initializer_list<t_INIT_LIST_TYPE> il,
7567 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7568 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7569 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7570 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7571 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7572 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7573 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
7574{
7575 reset();
7576 BloombergLP::bslma::ConstructionUtil::construct(
7577 d_buffer.address(),
7578 allocator,
7579 il,
7580 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7581 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7582 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7583 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7584 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7585 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7586 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
7587 d_hasValue = true;
7588 return d_buffer.object();
7589}
7590#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 7
7591
7592#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 8
7593template <class t_TYPE>
7594template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7595 class t_ARGS_02,
7596 class t_ARGS_03,
7597 class t_ARGS_04,
7598 class t_ARGS_05,
7599 class t_ARGS_06,
7600 class t_ARGS_07,
7601 class t_ARGS_08>
7602t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7603 bslma::Allocator *allocator,
7604 std::initializer_list<t_INIT_LIST_TYPE> il,
7605 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7606 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7607 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7608 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7609 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7610 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7611 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7612 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
7613{
7614 reset();
7615 BloombergLP::bslma::ConstructionUtil::construct(
7616 d_buffer.address(),
7617 allocator,
7618 il,
7619 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7620 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7621 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7622 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7623 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7624 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7625 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7626 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
7627 d_hasValue = true;
7628 return d_buffer.object();
7629}
7630#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 8
7631
7632#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 9
7633template <class t_TYPE>
7634template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7635 class t_ARGS_02,
7636 class t_ARGS_03,
7637 class t_ARGS_04,
7638 class t_ARGS_05,
7639 class t_ARGS_06,
7640 class t_ARGS_07,
7641 class t_ARGS_08,
7642 class t_ARGS_09>
7643t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7644 bslma::Allocator *allocator,
7645 std::initializer_list<t_INIT_LIST_TYPE> il,
7646 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7647 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7648 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7649 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7650 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7651 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7652 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7653 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
7654 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
7655{
7656 reset();
7657 BloombergLP::bslma::ConstructionUtil::construct(
7658 d_buffer.address(),
7659 allocator,
7660 il,
7661 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7662 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7663 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7664 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7665 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7666 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7667 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7668 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
7669 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
7670 d_hasValue = true;
7671 return d_buffer.object();
7672}
7673#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 9
7674
7675#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 10
7676template <class t_TYPE>
7677template <class t_INIT_LIST_TYPE, class t_ARGS_01,
7678 class t_ARGS_02,
7679 class t_ARGS_03,
7680 class t_ARGS_04,
7681 class t_ARGS_05,
7682 class t_ARGS_06,
7683 class t_ARGS_07,
7684 class t_ARGS_08,
7685 class t_ARGS_09,
7686 class t_ARGS_10>
7687t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7688 bslma::Allocator *allocator,
7689 std::initializer_list<t_INIT_LIST_TYPE> il,
7690 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
7691 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
7692 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
7693 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
7694 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
7695 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
7696 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
7697 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
7698 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
7699 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
7700{
7701 reset();
7702 BloombergLP::bslma::ConstructionUtil::construct(
7703 d_buffer.address(),
7704 allocator,
7705 il,
7706 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
7707 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
7708 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
7709 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
7710 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
7711 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
7712 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
7713 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
7714 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
7715 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
7716 d_hasValue = true;
7717 return d_buffer.object();
7718}
7719#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_L >= 10
7720
7721# endif
7722#else
7723// The generated code below is a workaround for the absence of perfect
7724// forwarding in some compilers.
7725template <class t_TYPE>
7726template <class... t_ARGS>
7727inline
7728t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7729 bslma::Allocator *allocator,
7730 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
7731{
7732 reset();
7733 BloombergLP::bslma::ConstructionUtil::construct(
7734 d_buffer.address(),
7735 allocator,
7736 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
7737 d_hasValue = true;
7738 return d_buffer.object();
7739}
7740
7741# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
7742template <class t_TYPE>
7743template <class t_INIT_LIST_TYPE, class... t_ARGS>
7744t_TYPE& Optional_DataImp<t_TYPE>::emplace(
7745 bslma::Allocator *allocator,
7746 std::initializer_list<t_INIT_LIST_TYPE> il,
7747 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
7748{
7749 reset();
7750 BloombergLP::bslma::ConstructionUtil::construct(
7751 d_buffer.address(),
7752 allocator,
7753 il,
7754 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
7755 d_hasValue = true;
7756 return d_buffer.object();
7757}
7758# endif
7759// }}} END GENERATED CODE
7760#endif
7761
7762template <class t_TYPE>
7763void Optional_DataImp<t_TYPE>::reset() BSLS_KEYWORD_NOEXCEPT
7764{
7765 if (d_hasValue) {
7766 d_hasValue = false;
7767 bslma::DestructionUtil::destroy(d_buffer.address());
7768 }
7769}
7770
7771# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
7772template <class t_TYPE>
7773inline
7774t_TYPE& Optional_DataImp<t_TYPE>::value() &
7775{
7776 // We do not assert on an empty object in this function as the assert level
7777 // is determined by the 'Optional_Base' method invoking 'value()'
7778
7779 return d_buffer.object();
7780}
7781
7782template <class t_TYPE>
7783inline
7784t_TYPE&& Optional_DataImp<t_TYPE>::value() &&
7785{
7786 // We do not assert on an empty object in this function as the assert level
7787 // is determined by the 'Optional_Base' method invoking 'value()'
7788
7789 return std::move(d_buffer.object());
7790}
7791# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
7792template <class t_TYPE>
7793inline
7794t_TYPE& Optional_DataImp<t_TYPE>::value()
7795{
7796 // We do not assert on an empty object in this function as the assert level
7797 // is determined by the 'Optional_Base' method invoking 'value()'
7798
7799 return d_buffer.object();
7800}
7801# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
7802
7803// ACCESSORS
7804template <class t_TYPE>
7805inline
7806bool Optional_DataImp<t_TYPE>::hasValue() const BSLS_KEYWORD_NOEXCEPT
7807{
7808#ifdef BSLS_PLATFORM_CMP_GNU
7809# pragma GCC diagnostic push
7810# pragma GCC diagnostic ignored "-Warray-bounds"
7811#endif
7812 return d_hasValue;
7813#ifdef BSLS_PLATFORM_CMP_GNU
7814# pragma GCC diagnostic pop
7815#endif
7816}
7817
7818# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
7819template <class t_TYPE>
7820inline
7821const t_TYPE& Optional_DataImp<t_TYPE>::value() const&
7822{
7823 // We do not assert on an empty object in this function as the assert level
7824 // is determined by the 'Optional_Base' method invoking 'value()'
7825
7826 return d_buffer.object();
7827}
7828
7829template <class t_TYPE>
7830inline
7831const t_TYPE&& Optional_DataImp<t_TYPE>::value() const&&
7832{
7833 // We do not assert on an empty object in this function as the assert level
7834 // is determined by the 'Optional_Base' method invoking 'value()'
7835
7836 return std::move(d_buffer.object());
7837}
7838# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
7839template <class t_TYPE>
7840inline
7841const t_TYPE& Optional_DataImp<t_TYPE>::value() const
7842{
7843 // We do not assert on an empty object in this function as the assert level
7844 // is determined by the 'Optional_Base' method invoking 'value()'
7845
7846 return d_buffer.object();
7847}
7848# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
7849
7850 // ===================
7851 // class Optional_Data
7852 // ===================
7853
7854// CREATORS
7855template <class t_TYPE, bool t_IS_TRIVIALLY_DESTRUCTIBLE>
7856Optional_Data<t_TYPE, t_IS_TRIVIALLY_DESTRUCTIBLE>::~Optional_Data()
7857{
7858 this->reset();
7859}
7860
7861// ============================================================================
7862// Section: Allocator-Aware 'Optional_Base' Method Definitions
7863// ============================================================================
7864
7865 // ===================
7866 // class Optional_Base
7867 // ===================
7868
7869// PROTECTED CREATORS
7870template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7871inline
7872Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base()
7873{
7874}
7875
7876template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7877inline
7878Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(bsl::nullopt_t)
7879{
7880}
7881
7882template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7883inline
7884Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7885 const Optional_Base& original)
7886{
7887 if (original.has_value()) {
7888 emplace(*original);
7889 }
7890}
7891
7892template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7893inline
7894Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7895 BloombergLP::bslmf::MovableRef<Optional_Base> original)
7898: d_allocator(MoveUtil::access(original).get_allocator())
7899{
7900 Optional_Base& lvalue = original;
7901
7902 if (lvalue.has_value()) {
7903 emplace(MoveUtil::move(*lvalue));
7904 }
7905}
7906
7907template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7908template <class t_ANY_TYPE>
7909inline
7910Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7911 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
7912 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
7913{
7914 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value));
7915}
7916
7917template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7918template <class t_ANY_TYPE>
7919inline
7920Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7921 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
7922 const Optional_Base<t_ANY_TYPE>& original)
7923{
7924 if (original.has_value()) {
7925 emplace(original.value());
7926 }
7927}
7928
7929template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7930template <class t_ANY_TYPE>
7931inline
7932Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7933 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
7934 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original,
7936 t_ANY_TYPE))
7937{
7938 Optional_Base<t_ANY_TYPE>& lvalue = original;
7939 if (lvalue.has_value()) {
7940 emplace(MoveUtil::move(*lvalue));
7941 }
7942}
7943
7944template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7945template <class t_ANY_TYPE>
7946inline
7947Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7948 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
7949 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original,
7951 t_ANY_TYPE))
7952: d_allocator(MoveUtil::access(original).get_allocator())
7953{
7954 Optional_Base<t_ANY_TYPE>& lvalue = original;
7955 if (lvalue.has_value()) {
7956 emplace(MoveUtil::move(*lvalue));
7957 }
7958}
7959
7960# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
7961template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7962template <class t_ANY_TYPE>
7963inline
7964Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7965 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
7966 const std::optional<t_ANY_TYPE>& original)
7967{
7968 if (original.has_value()) {
7969 emplace(original.value());
7970 }
7971}
7972
7973template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7974template <class t_ANY_TYPE>
7975inline
7976Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
7977 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
7978 std::optional<t_ANY_TYPE>&& original)
7979{
7980 if (original.has_value()) {
7981 emplace(std::move(original.value()));
7982 }
7983}
7984# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
7985
7986#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
7987// {{{ BEGIN GENERATED CODE
7988// Command line: sim_cpp11_features.pl bslstl_optional.h
7989#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
7990#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
7991#endif
7992#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_M
7993#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_M BSLSTL_OPTIONAL_VARIADIC_LIMIT
7994#endif
7995#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 0
7996template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
7997inline
7998Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8000{
8001 emplace();
8002}
8003#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 0
8004
8005#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 1
8006template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8007template <class t_ARGS_01>
8008inline
8009Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8011 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
8012{
8013 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
8014}
8015#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 1
8016
8017#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 2
8018template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8019template <class t_ARGS_01,
8020 class t_ARGS_02>
8021inline
8022Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
8026{
8027 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8028 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
8029}
8030#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 2
8031
8032#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 3
8033template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8034template <class t_ARGS_01,
8035 class t_ARGS_02,
8036 class t_ARGS_03>
8037inline
8038Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8040 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8041 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8042 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
8043{
8044 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8045 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8046 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
8047}
8048#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 3
8049
8050#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 4
8051template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8052template <class t_ARGS_01,
8053 class t_ARGS_02,
8054 class t_ARGS_03,
8055 class t_ARGS_04>
8056inline
8057Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8059 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8060 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8061 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8062 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
8063{
8064 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8065 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8066 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8067 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
8068}
8069#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 4
8070
8071#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 5
8072template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8073template <class t_ARGS_01,
8074 class t_ARGS_02,
8075 class t_ARGS_03,
8076 class t_ARGS_04,
8077 class t_ARGS_05>
8078inline
8079Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8081 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8082 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8083 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8084 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8085 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
8086{
8087 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8088 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8089 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8090 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8091 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
8092}
8093#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 5
8094
8095#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 6
8096template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8097template <class t_ARGS_01,
8098 class t_ARGS_02,
8099 class t_ARGS_03,
8100 class t_ARGS_04,
8101 class t_ARGS_05,
8102 class t_ARGS_06>
8103inline
8104Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8106 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8107 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8108 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8109 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8110 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
8112{
8113 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8114 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8115 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8116 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8117 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8118 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
8119}
8120#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 6
8121
8122#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 7
8123template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8124template <class t_ARGS_01,
8125 class t_ARGS_02,
8126 class t_ARGS_03,
8127 class t_ARGS_04,
8128 class t_ARGS_05,
8129 class t_ARGS_06,
8130 class t_ARGS_07>
8131inline
8132Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8134 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8135 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8136 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8137 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8138 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8139 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8140 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
8141{
8142 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8143 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8144 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8145 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8146 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8147 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8148 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
8149}
8150#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 7
8151
8152#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 8
8153template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8154template <class t_ARGS_01,
8155 class t_ARGS_02,
8156 class t_ARGS_03,
8157 class t_ARGS_04,
8158 class t_ARGS_05,
8159 class t_ARGS_06,
8160 class t_ARGS_07,
8161 class t_ARGS_08>
8162inline
8163Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8165 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8166 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8167 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8168 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8169 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8170 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8171 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8172 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
8173{
8174 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8175 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8176 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8177 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8178 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8179 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8180 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8181 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
8182}
8183#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 8
8184
8185#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 9
8186template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8187template <class t_ARGS_01,
8188 class t_ARGS_02,
8189 class t_ARGS_03,
8190 class t_ARGS_04,
8191 class t_ARGS_05,
8192 class t_ARGS_06,
8193 class t_ARGS_07,
8194 class t_ARGS_08,
8195 class t_ARGS_09>
8196inline
8197Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8199 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8200 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8201 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8202 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8203 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8204 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8205 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8206 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8207 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
8208{
8209 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8210 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8211 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8212 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8213 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8214 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8215 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8216 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
8217 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
8218}
8219#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 9
8220
8221#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 10
8222template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8223template <class t_ARGS_01,
8224 class t_ARGS_02,
8225 class t_ARGS_03,
8226 class t_ARGS_04,
8227 class t_ARGS_05,
8228 class t_ARGS_06,
8229 class t_ARGS_07,
8230 class t_ARGS_08,
8231 class t_ARGS_09,
8232 class t_ARGS_10>
8233inline
8234Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8236 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8237 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8238 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8239 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8241 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8242 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8243 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8244 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
8245 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
8246{
8247 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8248 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8249 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8250 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8251 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8252 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8253 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8254 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
8255 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
8256 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
8257}
8258#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 10
8259
8260
8261# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
8262#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 0
8263template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8264template <class t_INIT_LIST_TYPE>
8265inline
8266Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8268 std::initializer_list<t_INIT_LIST_TYPE> il)
8269{
8270 emplace(il);
8271}
8272#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 0
8273
8274#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 1
8275template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8276template <class t_INIT_LIST_TYPE, class t_ARGS_01>
8277inline
8278Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8280 std::initializer_list<t_INIT_LIST_TYPE> il,
8281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
8282{
8283 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
8284}
8285#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 1
8286
8287#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 2
8288template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8289template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8290 class t_ARGS_02>
8291inline
8292Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8294 std::initializer_list<t_INIT_LIST_TYPE> il,
8295 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8296 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
8297{
8298 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8299 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
8300}
8301#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 2
8302
8303#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 3
8304template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8305template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8306 class t_ARGS_02,
8307 class t_ARGS_03>
8308inline
8309Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8311 std::initializer_list<t_INIT_LIST_TYPE> il,
8312 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8313 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8314 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
8315{
8316 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8317 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8318 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
8319}
8320#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 3
8321
8322#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 4
8323template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8324template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8325 class t_ARGS_02,
8326 class t_ARGS_03,
8327 class t_ARGS_04>
8328inline
8329Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8331 std::initializer_list<t_INIT_LIST_TYPE> il,
8332 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8333 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8334 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8335 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
8336{
8337 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8338 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8339 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8340 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
8341}
8342#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 4
8343
8344#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 5
8345template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8346template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8347 class t_ARGS_02,
8348 class t_ARGS_03,
8349 class t_ARGS_04,
8350 class t_ARGS_05>
8351inline
8352Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8354 std::initializer_list<t_INIT_LIST_TYPE> il,
8355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8357 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8358 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8359 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
8360{
8361 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8362 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8363 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8364 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8365 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
8366}
8367#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 5
8368
8369#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 6
8370template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8371template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8372 class t_ARGS_02,
8373 class t_ARGS_03,
8374 class t_ARGS_04,
8375 class t_ARGS_05,
8376 class t_ARGS_06>
8377inline
8378Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8380 std::initializer_list<t_INIT_LIST_TYPE> il,
8381 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8382 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8383 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8384 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8385 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8386 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
8387{
8388 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8389 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8390 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8391 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8392 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8393 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
8394}
8395#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 6
8396
8397#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 7
8398template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8399template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8400 class t_ARGS_02,
8401 class t_ARGS_03,
8402 class t_ARGS_04,
8403 class t_ARGS_05,
8404 class t_ARGS_06,
8405 class t_ARGS_07>
8406inline
8407Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8409 std::initializer_list<t_INIT_LIST_TYPE> il,
8410 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8411 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8412 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8413 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8414 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8415 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8416 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
8417{
8418 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8419 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8420 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8421 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8422 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8423 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8424 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
8425}
8426#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 7
8427
8428#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 8
8429template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8430template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8431 class t_ARGS_02,
8432 class t_ARGS_03,
8433 class t_ARGS_04,
8434 class t_ARGS_05,
8435 class t_ARGS_06,
8436 class t_ARGS_07,
8437 class t_ARGS_08>
8438inline
8439Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8441 std::initializer_list<t_INIT_LIST_TYPE> il,
8442 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8443 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8444 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8445 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8446 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8447 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8448 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8449 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
8450{
8451 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8452 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8453 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8454 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8455 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8456 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8457 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8458 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
8459}
8460#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 8
8461
8462#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 9
8463template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8464template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8465 class t_ARGS_02,
8466 class t_ARGS_03,
8467 class t_ARGS_04,
8468 class t_ARGS_05,
8469 class t_ARGS_06,
8470 class t_ARGS_07,
8471 class t_ARGS_08,
8472 class t_ARGS_09>
8473inline
8474Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8476 std::initializer_list<t_INIT_LIST_TYPE> il,
8477 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8478 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8479 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8480 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8481 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8482 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8483 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8484 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8485 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
8486{
8487 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8488 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8489 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8490 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8491 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8492 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8493 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8494 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
8495 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
8496}
8497#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 9
8498
8499#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 10
8500template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8501template <class t_INIT_LIST_TYPE, class t_ARGS_01,
8502 class t_ARGS_02,
8503 class t_ARGS_03,
8504 class t_ARGS_04,
8505 class t_ARGS_05,
8506 class t_ARGS_06,
8507 class t_ARGS_07,
8508 class t_ARGS_08,
8509 class t_ARGS_09,
8510 class t_ARGS_10>
8511inline
8512Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8514 std::initializer_list<t_INIT_LIST_TYPE> il,
8515 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8516 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8517 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8518 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8519 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8520 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8521 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8522 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8523 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
8524 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
8525{
8526 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8527 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8528 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8529 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8530 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8531 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8532 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8533 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
8534 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
8535 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
8536}
8537#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_M >= 10
8538
8539# endif
8540#else
8541// The generated code below is a workaround for the absence of perfect
8542// forwarding in some compilers.
8543template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8544template <class... t_ARGS>
8545inline
8546Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8548 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
8549{
8550 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
8551}
8552
8553# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
8554template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8555template <class t_INIT_LIST_TYPE, class... t_ARGS>
8556inline
8557Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8559 std::initializer_list<t_INIT_LIST_TYPE> il,
8560 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
8561{
8562 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
8563}
8564# endif
8565// }}} END GENERATED CODE
8566#endif
8567
8568#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
8569template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8570template <class t_INVOCABLE, class t_ARG>
8571inline
8572Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8573 Optional_InvokeConstructorTag tag,
8574 t_INVOCABLE&& invocable,
8575 t_ARG&& arg)
8576: d_value(tag, std::forward<t_INVOCABLE>(invocable), std::forward<t_ARG>(arg))
8577, d_allocator(bslma::AATypeUtil::getAllocatorFromSubobject<allocator_type>(
8578 d_value.value()))
8579{
8580}
8581#endif
8582
8583template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8584inline
8585Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8587 allocator_type allocator)
8588: d_allocator(allocator)
8589{
8590}
8591
8592template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8593inline
8594Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8596 allocator_type allocator,
8598: d_allocator(allocator)
8599{
8600}
8601
8602template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8603inline
8604Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8606 allocator_type allocator,
8607 const Optional_Base& original)
8608: d_allocator(allocator)
8609{
8610 if (original.has_value()) {
8611 emplace(*original);
8612 }
8613}
8614
8615template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8616inline
8617Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8619 allocator_type allocator,
8620 BloombergLP::bslmf::MovableRef<Optional_Base> original)
8621: d_allocator(allocator)
8622{
8623 Optional_Base& lvalue = original;
8624
8625 if (lvalue.has_value()) {
8626 emplace(MoveUtil::move(*lvalue));
8627 }
8628}
8629
8630template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8631template <class t_ANY_TYPE>
8632inline
8633Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8635 allocator_type allocator,
8636 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
8637 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
8638: d_allocator(allocator)
8639{
8640 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value));
8641}
8642
8643template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8644template <class t_ANY_TYPE>
8645inline
8646Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8648 allocator_type allocator,
8649 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
8650 const Optional_Base<t_ANY_TYPE>& original)
8651: d_allocator(allocator)
8652{
8653 if (original.has_value()) {
8654 emplace(original.value());
8655 }
8656}
8657
8658template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8659template <class t_ANY_TYPE>
8660inline
8661Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8663 allocator_type allocator,
8664 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
8665 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original)
8666: d_allocator(allocator)
8667{
8668 Optional_Base<t_ANY_TYPE>& lvalue = original;
8669 if (lvalue.has_value()) {
8670 emplace(MoveUtil::move(*lvalue));
8671 }
8672}
8673
8674# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
8675template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8676template <class t_ANY_TYPE>
8677inline
8678Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8680 allocator_type allocator,
8681 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
8682 const std::optional<t_ANY_TYPE>& original)
8683: d_allocator(allocator)
8684{
8685 if (original.has_value()) {
8686 emplace(original.value());
8687 }
8688}
8689
8690template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8691template <class t_ANY_TYPE>
8692inline
8693Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8695 allocator_type allocator,
8696 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
8697 std::optional<t_ANY_TYPE>&& original)
8698: d_allocator(allocator)
8699{
8700 if (original.has_value()) {
8701 emplace(std::move(original.value()));
8702 }
8703}
8704# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
8705
8706#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
8707// {{{ BEGIN GENERATED CODE
8708// Command line: sim_cpp11_features.pl bslstl_optional.h
8709#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
8710#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
8711#endif
8712#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_N
8713#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_N BSLSTL_OPTIONAL_VARIADIC_LIMIT
8714#endif
8715#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 0
8716template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8717inline
8718Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8720 allocator_type alloc,
8722: d_allocator(alloc)
8723{
8724 emplace();
8725}
8726#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 0
8727
8728#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 1
8729template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8730template <class t_ARGS_01>
8731inline
8732Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8734 allocator_type alloc,
8736 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
8737: d_allocator(alloc)
8738{
8739 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
8740}
8741#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 1
8742
8743#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 2
8744template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8745template <class t_ARGS_01,
8746 class t_ARGS_02>
8747inline
8748Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8750 allocator_type alloc,
8752 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8753 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
8754: d_allocator(alloc)
8755{
8756 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8757 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
8758}
8759#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 2
8760
8761#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 3
8762template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8763template <class t_ARGS_01,
8764 class t_ARGS_02,
8765 class t_ARGS_03>
8766inline
8767Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8769 allocator_type alloc,
8771 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8773 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
8774: d_allocator(alloc)
8775{
8776 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8777 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8778 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
8779}
8780#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 3
8781
8782#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 4
8783template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8784template <class t_ARGS_01,
8785 class t_ARGS_02,
8786 class t_ARGS_03,
8787 class t_ARGS_04>
8788inline
8789Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8791 allocator_type alloc,
8793 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8794 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8795 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8796 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
8797: d_allocator(alloc)
8798{
8799 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8800 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8801 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8802 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
8803}
8804#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 4
8805
8806#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 5
8807template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8808template <class t_ARGS_01,
8809 class t_ARGS_02,
8810 class t_ARGS_03,
8811 class t_ARGS_04,
8812 class t_ARGS_05>
8813inline
8814Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8816 allocator_type alloc,
8818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8820 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8821 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8822 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
8823: d_allocator(alloc)
8824{
8825 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8826 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8827 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8828 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8829 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
8830}
8831#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 5
8832
8833#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 6
8834template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8835template <class t_ARGS_01,
8836 class t_ARGS_02,
8837 class t_ARGS_03,
8838 class t_ARGS_04,
8839 class t_ARGS_05,
8840 class t_ARGS_06>
8841inline
8842Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8844 allocator_type alloc,
8846 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8847 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8848 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8849 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8850 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8851 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
8852: d_allocator(alloc)
8853{
8854 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8855 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8856 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8857 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8858 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8859 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
8860}
8861#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 6
8862
8863#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 7
8864template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8865template <class t_ARGS_01,
8866 class t_ARGS_02,
8867 class t_ARGS_03,
8868 class t_ARGS_04,
8869 class t_ARGS_05,
8870 class t_ARGS_06,
8871 class t_ARGS_07>
8872inline
8873Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8875 allocator_type alloc,
8877 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8878 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8879 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8880 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8881 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8882 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8883 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
8884: d_allocator(alloc)
8885{
8886 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8887 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8888 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8889 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8890 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8891 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8892 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
8893}
8894#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 7
8895
8896#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 8
8897template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8898template <class t_ARGS_01,
8899 class t_ARGS_02,
8900 class t_ARGS_03,
8901 class t_ARGS_04,
8902 class t_ARGS_05,
8903 class t_ARGS_06,
8904 class t_ARGS_07,
8905 class t_ARGS_08>
8906inline
8907Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8909 allocator_type alloc,
8911 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8912 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8913 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8914 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8915 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8916 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8917 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8918 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
8919: d_allocator(alloc)
8920{
8921 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8922 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8923 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8924 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8925 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8926 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8927 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8928 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
8929}
8930#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 8
8931
8932#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 9
8933template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8934template <class t_ARGS_01,
8935 class t_ARGS_02,
8936 class t_ARGS_03,
8937 class t_ARGS_04,
8938 class t_ARGS_05,
8939 class t_ARGS_06,
8940 class t_ARGS_07,
8941 class t_ARGS_08,
8942 class t_ARGS_09>
8943inline
8944Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8946 allocator_type alloc,
8948 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8949 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8950 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8951 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8952 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8953 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8954 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8955 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8956 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
8957: d_allocator(alloc)
8958{
8959 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
8960 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
8961 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
8962 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
8963 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
8964 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
8965 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
8966 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
8967 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
8968}
8969#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 9
8970
8971#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 10
8972template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
8973template <class t_ARGS_01,
8974 class t_ARGS_02,
8975 class t_ARGS_03,
8976 class t_ARGS_04,
8977 class t_ARGS_05,
8978 class t_ARGS_06,
8979 class t_ARGS_07,
8980 class t_ARGS_08,
8981 class t_ARGS_09,
8982 class t_ARGS_10>
8983inline
8984Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
8986 allocator_type alloc,
8988 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
8989 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
8990 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
8991 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
8992 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
8993 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
8994 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
8995 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
8996 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
8997 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
8998: d_allocator(alloc)
8999{
9000 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9001 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9002 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9003 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9004 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9005 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9006 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9007 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9008 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
9009 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
9010}
9011#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 10
9012
9013
9014# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
9015#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 0
9016template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9017template <class t_INIT_LIST_TYPE>
9018inline
9019Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9021 allocator_type alloc,
9023 std::initializer_list<t_INIT_LIST_TYPE> il)
9024: d_allocator(alloc)
9025{
9026 emplace(il);
9027}
9028#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 0
9029
9030#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 1
9031template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9032template <class t_INIT_LIST_TYPE, class t_ARGS_01>
9033inline
9034Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9036 allocator_type alloc,
9038 std::initializer_list<t_INIT_LIST_TYPE> il,
9039 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
9040: d_allocator(alloc)
9041{
9042 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
9043}
9044#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 1
9045
9046#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 2
9047template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9048template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9049 class t_ARGS_02>
9050inline
9051Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9053 allocator_type alloc,
9055 std::initializer_list<t_INIT_LIST_TYPE> il,
9056 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9057 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
9058: d_allocator(alloc)
9059{
9060 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9061 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
9062}
9063#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 2
9064
9065#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 3
9066template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9067template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9068 class t_ARGS_02,
9069 class t_ARGS_03>
9070inline
9071Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9073 allocator_type alloc,
9075 std::initializer_list<t_INIT_LIST_TYPE> il,
9076 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9077 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9078 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
9079: d_allocator(alloc)
9080{
9081 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9082 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9083 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
9084}
9085#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 3
9086
9087#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 4
9088template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9089template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9090 class t_ARGS_02,
9091 class t_ARGS_03,
9092 class t_ARGS_04>
9093inline
9094Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9096 allocator_type alloc,
9098 std::initializer_list<t_INIT_LIST_TYPE> il,
9099 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9100 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9101 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9102 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
9103: d_allocator(alloc)
9104{
9105 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9106 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9107 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9108 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
9109}
9110#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 4
9111
9112#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 5
9113template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9114template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9115 class t_ARGS_02,
9116 class t_ARGS_03,
9117 class t_ARGS_04,
9118 class t_ARGS_05>
9119inline
9120Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9122 allocator_type alloc,
9124 std::initializer_list<t_INIT_LIST_TYPE> il,
9125 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9126 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9127 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9128 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9129 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
9130: d_allocator(alloc)
9131{
9132 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9133 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9134 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9135 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9136 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
9137}
9138#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 5
9139
9140#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 6
9141template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9142template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9143 class t_ARGS_02,
9144 class t_ARGS_03,
9145 class t_ARGS_04,
9146 class t_ARGS_05,
9147 class t_ARGS_06>
9148inline
9149Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9151 allocator_type alloc,
9153 std::initializer_list<t_INIT_LIST_TYPE> il,
9154 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9155 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9156 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9157 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9158 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9159 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
9160: d_allocator(alloc)
9161{
9162 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9163 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9164 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9165 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9166 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9167 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
9168}
9169#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 6
9170
9171#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 7
9172template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9173template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9174 class t_ARGS_02,
9175 class t_ARGS_03,
9176 class t_ARGS_04,
9177 class t_ARGS_05,
9178 class t_ARGS_06,
9179 class t_ARGS_07>
9180inline
9181Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9183 allocator_type alloc,
9185 std::initializer_list<t_INIT_LIST_TYPE> il,
9186 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9187 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9188 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9189 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9190 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9191 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9192 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
9193: d_allocator(alloc)
9194{
9195 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9196 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9197 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9198 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9199 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9200 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9201 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
9202}
9203#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 7
9204
9205#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 8
9206template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9207template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9208 class t_ARGS_02,
9209 class t_ARGS_03,
9210 class t_ARGS_04,
9211 class t_ARGS_05,
9212 class t_ARGS_06,
9213 class t_ARGS_07,
9214 class t_ARGS_08>
9215inline
9216Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9218 allocator_type alloc,
9220 std::initializer_list<t_INIT_LIST_TYPE> il,
9221 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9222 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9223 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9224 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9225 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9226 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9227 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9228 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
9229: d_allocator(alloc)
9230{
9231 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9232 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9233 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9234 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9235 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9236 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9237 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9238 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
9239}
9240#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 8
9241
9242#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 9
9243template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9244template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9245 class t_ARGS_02,
9246 class t_ARGS_03,
9247 class t_ARGS_04,
9248 class t_ARGS_05,
9249 class t_ARGS_06,
9250 class t_ARGS_07,
9251 class t_ARGS_08,
9252 class t_ARGS_09>
9253inline
9254Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9256 allocator_type alloc,
9258 std::initializer_list<t_INIT_LIST_TYPE> il,
9259 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9260 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9261 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9262 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9263 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9265 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9266 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9267 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
9268: d_allocator(alloc)
9269{
9270 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9271 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9272 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9273 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9274 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9275 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9276 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9277 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9278 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
9279}
9280#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 9
9281
9282#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 10
9283template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9284template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9285 class t_ARGS_02,
9286 class t_ARGS_03,
9287 class t_ARGS_04,
9288 class t_ARGS_05,
9289 class t_ARGS_06,
9290 class t_ARGS_07,
9291 class t_ARGS_08,
9292 class t_ARGS_09,
9293 class t_ARGS_10>
9294inline
9295Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9297 allocator_type alloc,
9299 std::initializer_list<t_INIT_LIST_TYPE> il,
9300 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9301 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9302 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9303 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9304 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9305 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9306 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9308 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
9309 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
9310: d_allocator(alloc)
9311{
9312 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9313 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9314 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9315 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9316 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9317 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9318 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9319 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9320 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
9321 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
9322}
9323#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_N >= 10
9324
9325# endif
9326#else
9327// The generated code below is a workaround for the absence of perfect
9328// forwarding in some compilers.
9329template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9330template <class... t_ARGS>
9331inline
9332Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9334 allocator_type alloc,
9336 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
9337: d_allocator(alloc)
9338{
9339 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
9340}
9341
9342# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
9343template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9344template <class t_INIT_LIST_TYPE, class... t_ARGS>
9345inline
9346Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::Optional_Base(
9348 allocator_type alloc,
9350 std::initializer_list<t_INIT_LIST_TYPE> il,
9351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
9352: d_allocator(alloc)
9353{
9354 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
9355}
9356# endif
9357// }}} END GENERATED CODE
9358#endif
9359
9360// PROTECTED MANIPULATORS
9361template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9362template <class t_ANY_TYPE>
9363void Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::assignOrEmplace(
9364 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) rhs)
9365{
9366 if (has_value()) {
9367 d_value.value() = BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, rhs);
9368 } else {
9369 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, rhs));
9370 }
9371}
9372
9373# ifndef BDE_OMIT_INTERNAL_DEPRECATED
9374template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9375t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::dereferenceRaw()
9376{
9377 // This method is provided for the purpose of allowing 'NullableValue' to
9378 // determine the assert level in its value() method. Do not assert here.
9379
9380 return d_value.value();
9381}
9382
9383// PROTECTED ACCESORS
9384template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9385const t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::dereferenceRaw() const
9386{
9387 // This method is provided for the purpose of allowing 'NullableValue' to
9388 // determine the assert level in its value() method. Do not assert here.
9389
9390 return d_value.value();
9391}
9392# endif // BDE_OMIT_INTERNAL_DEPRECATED
9393
9394// MANIPULATORS
9395#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
9396// {{{ BEGIN GENERATED CODE
9397// Command line: sim_cpp11_features.pl bslstl_optional.h
9398#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
9399#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
9400#endif
9401#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_O
9402#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_O BSLSTL_OPTIONAL_VARIADIC_LIMIT
9403#endif
9404#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 0
9405template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9406inline
9407t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9408 )
9409{
9410 return d_value.emplace(d_allocator.mechanism());
9411}
9412#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 0
9413
9414#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 1
9415template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9416template <class t_ARGS_01>
9417inline
9418t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9419 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
9420{
9421 return d_value.emplace(d_allocator.mechanism(),
9422 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
9423}
9424#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 1
9425
9426#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 2
9427template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9428template <class t_ARGS_01,
9429 class t_ARGS_02>
9430inline
9431t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9432 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9433 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
9434{
9435 return d_value.emplace(d_allocator.mechanism(),
9436 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9437 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
9438}
9439#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 2
9440
9441#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 3
9442template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9443template <class t_ARGS_01,
9444 class t_ARGS_02,
9445 class t_ARGS_03>
9446inline
9447t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9448 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9449 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9450 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
9451{
9452 return d_value.emplace(d_allocator.mechanism(),
9453 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9454 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9455 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
9456}
9457#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 3
9458
9459#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 4
9460template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9461template <class t_ARGS_01,
9462 class t_ARGS_02,
9463 class t_ARGS_03,
9464 class t_ARGS_04>
9465inline
9466t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9467 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9468 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9469 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9470 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
9471{
9472 return d_value.emplace(d_allocator.mechanism(),
9473 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9474 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9475 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9476 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
9477}
9478#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 4
9479
9480#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 5
9481template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9482template <class t_ARGS_01,
9483 class t_ARGS_02,
9484 class t_ARGS_03,
9485 class t_ARGS_04,
9486 class t_ARGS_05>
9487inline
9488t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9489 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9490 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9491 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9492 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9493 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
9494{
9495 return d_value.emplace(d_allocator.mechanism(),
9496 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9497 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9498 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9499 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9500 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
9501}
9502#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 5
9503
9504#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 6
9505template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9506template <class t_ARGS_01,
9507 class t_ARGS_02,
9508 class t_ARGS_03,
9509 class t_ARGS_04,
9510 class t_ARGS_05,
9511 class t_ARGS_06>
9512inline
9513t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9514 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9515 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9516 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9517 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9518 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9519 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
9520{
9521 return d_value.emplace(d_allocator.mechanism(),
9522 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9523 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9524 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9525 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9526 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9527 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
9528}
9529#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 6
9530
9531#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 7
9532template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9533template <class t_ARGS_01,
9534 class t_ARGS_02,
9535 class t_ARGS_03,
9536 class t_ARGS_04,
9537 class t_ARGS_05,
9538 class t_ARGS_06,
9539 class t_ARGS_07>
9540inline
9541t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9542 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9543 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9544 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9545 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9546 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9547 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9548 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
9549{
9550 return d_value.emplace(d_allocator.mechanism(),
9551 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9552 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9553 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9554 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9555 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9556 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9557 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
9558}
9559#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 7
9560
9561#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 8
9562template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9563template <class t_ARGS_01,
9564 class t_ARGS_02,
9565 class t_ARGS_03,
9566 class t_ARGS_04,
9567 class t_ARGS_05,
9568 class t_ARGS_06,
9569 class t_ARGS_07,
9570 class t_ARGS_08>
9571inline
9572t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9573 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9574 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9575 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9576 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9577 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9578 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9579 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9580 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
9581{
9582 return d_value.emplace(d_allocator.mechanism(),
9583 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9584 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9585 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9586 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9587 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9588 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9589 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9590 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
9591}
9592#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 8
9593
9594#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 9
9595template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9596template <class t_ARGS_01,
9597 class t_ARGS_02,
9598 class t_ARGS_03,
9599 class t_ARGS_04,
9600 class t_ARGS_05,
9601 class t_ARGS_06,
9602 class t_ARGS_07,
9603 class t_ARGS_08,
9604 class t_ARGS_09>
9605inline
9606t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9607 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9608 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9609 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9610 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9611 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9612 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9613 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9614 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9615 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
9616{
9617 return d_value.emplace(d_allocator.mechanism(),
9618 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9619 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9620 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9621 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9622 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9623 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9624 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9625 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9626 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
9627}
9628#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 9
9629
9630#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 10
9631template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9632template <class t_ARGS_01,
9633 class t_ARGS_02,
9634 class t_ARGS_03,
9635 class t_ARGS_04,
9636 class t_ARGS_05,
9637 class t_ARGS_06,
9638 class t_ARGS_07,
9639 class t_ARGS_08,
9640 class t_ARGS_09,
9641 class t_ARGS_10>
9642inline
9643t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9644 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9645 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9646 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9647 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9648 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9649 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9650 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9651 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9652 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
9653 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
9654{
9655 return d_value.emplace(d_allocator.mechanism(),
9656 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9657 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9658 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9659 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9660 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9661 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9662 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9663 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9664 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
9665 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
9666}
9667#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 10
9668
9669
9670# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
9671#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 0
9672template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9673template <class t_INIT_LIST_TYPE>
9674t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9675 std::initializer_list<t_INIT_LIST_TYPE> il)
9676{
9677 return d_value.emplace(d_allocator.mechanism(),
9678 il);
9679}
9680#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 0
9681
9682#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 1
9683template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9684template <class t_INIT_LIST_TYPE, class t_ARGS_01>
9685t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9686 std::initializer_list<t_INIT_LIST_TYPE> il,
9687 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
9688{
9689 return d_value.emplace(d_allocator.mechanism(),
9690 il,
9691 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
9692}
9693#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 1
9694
9695#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 2
9696template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9697template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9698 class t_ARGS_02>
9699t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9700 std::initializer_list<t_INIT_LIST_TYPE> il,
9701 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9702 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
9703{
9704 return d_value.emplace(d_allocator.mechanism(),
9705 il,
9706 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9707 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
9708}
9709#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 2
9710
9711#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 3
9712template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9713template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9714 class t_ARGS_02,
9715 class t_ARGS_03>
9716t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9717 std::initializer_list<t_INIT_LIST_TYPE> il,
9718 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9719 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9720 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
9721{
9722 return d_value.emplace(d_allocator.mechanism(),
9723 il,
9724 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9725 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9726 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
9727}
9728#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 3
9729
9730#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 4
9731template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9732template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9733 class t_ARGS_02,
9734 class t_ARGS_03,
9735 class t_ARGS_04>
9736t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9737 std::initializer_list<t_INIT_LIST_TYPE> il,
9738 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9739 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9740 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9741 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
9742{
9743 return d_value.emplace(d_allocator.mechanism(),
9744 il,
9745 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9746 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9747 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9748 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
9749}
9750#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 4
9751
9752#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 5
9753template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9754template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9755 class t_ARGS_02,
9756 class t_ARGS_03,
9757 class t_ARGS_04,
9758 class t_ARGS_05>
9759t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9760 std::initializer_list<t_INIT_LIST_TYPE> il,
9761 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9762 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9763 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9764 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9765 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
9766{
9767 return d_value.emplace(d_allocator.mechanism(),
9768 il,
9769 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9770 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9771 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9772 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9773 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
9774}
9775#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 5
9776
9777#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 6
9778template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9779template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9780 class t_ARGS_02,
9781 class t_ARGS_03,
9782 class t_ARGS_04,
9783 class t_ARGS_05,
9784 class t_ARGS_06>
9785t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9786 std::initializer_list<t_INIT_LIST_TYPE> il,
9787 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9788 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9789 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9790 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9791 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9792 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
9793{
9794 return d_value.emplace(d_allocator.mechanism(),
9795 il,
9796 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9797 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9798 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9799 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9800 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9801 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
9802}
9803#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 6
9804
9805#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 7
9806template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9807template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9808 class t_ARGS_02,
9809 class t_ARGS_03,
9810 class t_ARGS_04,
9811 class t_ARGS_05,
9812 class t_ARGS_06,
9813 class t_ARGS_07>
9814t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9815 std::initializer_list<t_INIT_LIST_TYPE> il,
9816 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9817 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9820 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9821 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9822 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
9823{
9824 return d_value.emplace(d_allocator.mechanism(),
9825 il,
9826 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9827 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9828 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9829 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9830 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9831 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9832 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
9833}
9834#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 7
9835
9836#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 8
9837template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9838template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9839 class t_ARGS_02,
9840 class t_ARGS_03,
9841 class t_ARGS_04,
9842 class t_ARGS_05,
9843 class t_ARGS_06,
9844 class t_ARGS_07,
9845 class t_ARGS_08>
9846t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9847 std::initializer_list<t_INIT_LIST_TYPE> il,
9848 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9849 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9850 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9851 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9852 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9853 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9854 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9855 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
9856{
9857 return d_value.emplace(d_allocator.mechanism(),
9858 il,
9859 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9860 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9861 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9862 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9863 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9864 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9865 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9866 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
9867}
9868#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 8
9869
9870#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 9
9871template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9872template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9873 class t_ARGS_02,
9874 class t_ARGS_03,
9875 class t_ARGS_04,
9876 class t_ARGS_05,
9877 class t_ARGS_06,
9878 class t_ARGS_07,
9879 class t_ARGS_08,
9880 class t_ARGS_09>
9881t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9882 std::initializer_list<t_INIT_LIST_TYPE> il,
9883 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9884 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9885 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9886 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9887 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9888 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9889 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9890 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9891 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
9892{
9893 return d_value.emplace(d_allocator.mechanism(),
9894 il,
9895 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9896 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9897 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9898 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9899 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9900 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9901 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9902 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9903 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
9904}
9905#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 9
9906
9907#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 10
9908template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9909template <class t_INIT_LIST_TYPE, class t_ARGS_01,
9910 class t_ARGS_02,
9911 class t_ARGS_03,
9912 class t_ARGS_04,
9913 class t_ARGS_05,
9914 class t_ARGS_06,
9915 class t_ARGS_07,
9916 class t_ARGS_08,
9917 class t_ARGS_09,
9918 class t_ARGS_10>
9919t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9920 std::initializer_list<t_INIT_LIST_TYPE> il,
9921 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
9922 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
9923 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
9924 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
9925 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
9926 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
9927 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
9928 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
9929 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
9930 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
9931{
9932 return d_value.emplace(d_allocator.mechanism(),
9933 il,
9934 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
9935 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
9936 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
9937 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
9938 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
9939 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
9940 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
9941 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
9942 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
9943 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
9944}
9945#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_O >= 10
9946
9947# endif
9948#else
9949// The generated code below is a workaround for the absence of perfect
9950// forwarding in some compilers.
9951template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9952template <class... t_ARGS>
9953inline
9954t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9955 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
9956{
9957 return d_value.emplace(d_allocator.mechanism(),
9958 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
9959}
9960
9961# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
9962template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9963template <class t_INIT_LIST_TYPE, class... t_ARGS>
9964t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::emplace(
9965 std::initializer_list<t_INIT_LIST_TYPE> il,
9966 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
9967{
9968 return d_value.emplace(d_allocator.mechanism(),
9969 il,
9970 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
9971}
9972# endif
9973// }}} END GENERATED CODE
9974#endif
9975
9976template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9977inline
9978void Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::reset() BSLS_KEYWORD_NOEXCEPT
9979{
9980 d_value.reset();
9981}
9982
9983template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
9984void Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::swap(Optional_Base& other)
9987 bsl::is_nothrow_swappable<t_TYPE>::value)
9988{
9989 BSLS_ASSERT(d_allocator == other.d_allocator);
9990
9991 if (this->has_value() && other.has_value()) {
9992 BloombergLP::bslalg::SwapUtil::swap(
9993 BSLS_UTIL_ADDRESSOF(d_value.value()),
9994 BSLS_UTIL_ADDRESSOF(*other));
9995 }
9996 else if (this->has_value()) {
9997 other.emplace(MoveUtil::move(d_value.value()));
9998 this->reset();
9999 }
10000 else if (other.has_value()) {
10001 this->emplace(MoveUtil::move(*other));
10002 other.reset();
10003 }
10004}
10005
10006# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10007template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10008inline
10009t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value() &
10010{
10011 if (!has_value())
10012 BSLS_THROW(bsl::bad_optional_access());
10013
10014 return d_value.value();
10015}
10016
10017template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10018inline
10019t_TYPE&& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value() &&
10020{
10021 if (!has_value())
10022 BSLS_THROW(bsl::bad_optional_access());
10023
10024 return std::move(d_value.value());
10025}
10026
10027# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10028template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10029inline
10030t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value()
10031{
10032 if (!has_value())
10033 BSLS_THROW(bsl::bad_optional_access());
10034
10035 return d_value.value();
10036}
10037
10038# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
10039
10040# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10041template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10042template <class t_ANY_TYPE>
10043inline
10044t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10045 t_ANY_TYPE&& value) &&
10046{
10047 if (has_value()) {
10048 return t_TYPE(std::move(d_value.value())); // RETURN
10049 }
10050 else {
10051 return t_TYPE(std::forward<t_ANY_TYPE>(value)); // RETURN
10052 }
10053}
10054
10055# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10056template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10057template <class t_ANY_TYPE>
10058inline
10059t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10061 allocator_type allocator,
10062 t_ANY_TYPE&& value) &&
10063{
10064 if (has_value()) {
10065 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10066 allocator,
10067 std::move(d_value.value())); // RETURN
10068 }
10069 else {
10070 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10071 allocator,
10072 std::forward<t_ANY_TYPE>(value)); // RETURN
10073 }
10074}
10075# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10076# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10077
10078template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10079inline
10080Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>&
10081Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator=(const Optional_Base& rhs)
10082{
10083 if (rhs.has_value()) {
10084 if (this->has_value()) {
10085 d_value.value() = *rhs;
10086 }
10087 else {
10088 emplace(*rhs);
10089 }
10090 }
10091 else {
10092 reset();
10093 }
10094 return *this;
10095}
10096
10097template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10098inline
10099Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>&
10100Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator=(
10101 BloombergLP::bslmf::MovableRef<Optional_Base> rhs)
10102{
10103 Optional_Base& lvalue = rhs;
10104
10105 if (lvalue.has_value()) {
10106 if (this->has_value()) {
10107 d_value.value() = MoveUtil::move(*lvalue);
10108 }
10109 else {
10110 emplace(MoveUtil::move(*lvalue));
10111 }
10112 }
10113 else {
10114 reset();
10115 }
10116 return *this;
10117}
10118
10119template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10120inline
10121t_TYPE *Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator->()
10122{
10123 BSLS_ASSERT(has_value());
10124
10125 return BSLS_UTIL_ADDRESSOF(d_value.value());
10126}
10127
10128# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10129template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10130inline
10131t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*() &
10132{
10133 BSLS_ASSERT(has_value());
10134
10135 return d_value.value();
10136}
10137
10138template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10139inline
10140t_TYPE&& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*() &&
10141{
10142 BSLS_ASSERT(has_value());
10143
10144 return std::move(d_value.value());
10145}
10146
10147# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10148template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10149inline
10150t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*()
10151{
10152 BSLS_ASSERT(has_value());
10153
10154 return d_value.value();
10155}
10156
10157# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
10158
10159// ACCESSORS
10160
10161template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10162inline
10163typename Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::allocator_type
10164Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::get_allocator() const
10166{
10167 return d_allocator;
10168}
10169
10170template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10171inline
10172bool
10173Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::has_value() const
10175{
10176 return d_value.hasValue();
10177}
10178
10179# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10180template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10181inline
10182const t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value() const&
10183{
10184 if (!has_value())
10185 BSLS_THROW(bsl::bad_optional_access());
10186
10187 return d_value.value();
10188}
10189
10190template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10191inline
10192const t_TYPE&& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value() const&&
10193{
10194 if (!has_value())
10195 BSLS_THROW(bsl::bad_optional_access());
10196
10197 return std::move(d_value.value());
10198}
10199
10200# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10201template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10202inline
10203const t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value() const
10204{
10205 if (!has_value())
10206 BSLS_THROW(bsl::bad_optional_access());
10207
10208 return d_value.value();
10209}
10210
10211# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
10212
10213# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10214template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10215template <class t_ANY_TYPE>
10216inline
10217t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10218 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const&
10219{
10220 if (has_value()) {
10221 return t_TYPE(d_value.value()); // RETURN
10222 }
10223 else {
10224 return t_TYPE(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE,
10225 value)); // RETURN
10226 }
10227}
10228
10229# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10230template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10231template <class t_ANY_TYPE>
10232inline
10233t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10235 allocator_type allocator,
10236 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const&
10237{
10238 if (has_value()) {
10239 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10240 allocator, d_value.value()); // RETURN
10241 }
10242 else {
10243 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10244 allocator,
10245 BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value)); // RETURN
10246 }
10247}
10248# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10249# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10250template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10251template <class t_ANY_TYPE>
10252inline
10253t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10254 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const
10255{
10256 if (has_value()) {
10257 return t_TYPE(d_value.value()); // RETURN
10258 }
10259 else {
10260 return t_TYPE(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE,
10261 value)); // RETURN
10262 }
10263}
10264
10265# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10266template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10267template <class t_ANY_TYPE>
10268inline
10269t_TYPE Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::value_or(
10271 allocator_type allocator,
10272 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const
10273{
10274 if (has_value()) {
10275 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10276 allocator, d_value.value()); // RETURN
10277 }
10278 else {
10279 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
10280 allocator,
10281 BSLS_COMPILERFEATURES_FORWARD(ANY_TYPE, value)); // RETURN
10282 }
10283}
10284# endif // BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
10285# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
10286
10287template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10288inline
10289const t_TYPE *Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator->() const
10290{
10291 BSLS_ASSERT(has_value());
10292
10293 return BSLS_UTIL_ADDRESSOF(d_value.value());
10294}
10295
10296# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10297template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10298inline
10299const t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*() const&
10300{
10301 BSLS_ASSERT(has_value());
10302
10303 return d_value.value();
10304}
10305
10306template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10307inline
10308const t_TYPE&& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*() const&&
10309{
10310 BSLS_ASSERT(has_value());
10311
10312 return std::move(d_value.value());
10313}
10314
10315# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
10316template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10317inline
10318const t_TYPE& Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator*() const
10319{
10320 BSLS_ASSERT(has_value());
10321
10322 return d_value.value();
10323}
10324# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
10325
10326#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
10327template <class t_TYPE, bool t_USES_BSLMA_ALLOC>
10328Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>::operator bool() const
10330{
10331 return has_value();
10332}
10333#endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
10334
10335// ============================================================================
10336// Section: C++17 Allocator-Unaware 'Optional_Base' Method Definitions
10337// ============================================================================
10338
10339 // ==================================
10340 // class Optional_Base<t_TYPE, false>
10341 // ==================================
10342
10343# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
10344// PROTECTED CREATORS
10345template <class t_TYPE>
10346constexpr
10347Optional_Base<t_TYPE, false>::Optional_Base()
10348{
10349}
10350
10351template <class t_TYPE>
10352constexpr
10353Optional_Base<t_TYPE, false>::Optional_Base(bsl::nullopt_t)
10354{
10355}
10356
10357template <class t_TYPE>
10358template <class t_ANY_TYPE>
10359constexpr
10360Optional_Base<t_TYPE, false>::Optional_Base(
10361 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
10362 t_ANY_TYPE&& value)
10363: StdOptionalBase(std::forward<t_ANY_TYPE>(value))
10364{
10365}
10366
10367template <class t_TYPE>
10368template <class t_ANY_TYPE>
10370Optional_Base<t_TYPE, false>::Optional_Base(
10371 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
10372 const Optional_Base<t_ANY_TYPE>& original)
10373{
10374 if (original.has_value()) {
10375 this->emplace(original.value());
10376 }
10377}
10378
10379template <class t_TYPE>
10380template <class t_ANY_TYPE>
10382Optional_Base<t_TYPE, false>::Optional_Base(
10383 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
10384 Optional_Base<t_ANY_TYPE>&& original)
10385{
10386 if (original.has_value()) {
10387 this->emplace(std::move(original.value()));
10388 }
10389}
10390
10391template <class t_TYPE>
10392template <class t_ANY_TYPE>
10394Optional_Base<t_TYPE, false>::Optional_Base(
10395 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
10396 const std::optional<t_ANY_TYPE>& original)
10397: StdOptionalBase(original)
10398{
10399}
10400
10401template <class t_TYPE>
10402template <class t_ANY_TYPE>
10404Optional_Base<t_TYPE, false>::Optional_Base(
10405 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
10406 std::optional<t_ANY_TYPE>&& original)
10407: StdOptionalBase(std::move(original))
10408{
10409}
10410
10411template <class t_TYPE>
10412template <class... t_ARGS>
10413constexpr
10414Optional_Base<t_TYPE, false>::Optional_Base(bsl::in_place_t, t_ARGS&&... args)
10415: StdOptionalBase(bsl::in_place, std::forward<t_ARGS>(args)...)
10416{
10417}
10418
10419template <class t_TYPE>
10420template <class t_INIT_LIST_TYPE, class... t_ARGS>
10421constexpr
10422Optional_Base<t_TYPE, false>::Optional_Base(
10424 std::initializer_list<t_INIT_LIST_TYPE> il,
10425 t_ARGS&&... args)
10426: StdOptionalBase(bsl::in_place, il, std::forward<t_ARGS>(args)...)
10427{
10428}
10429
10430#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
10431template <class t_TYPE>
10432template <class t_INVOCABLE, class t_ARG>
10433inline
10434Optional_Base<t_TYPE, false>::Optional_Base(
10435 Optional_InvokeConstructorTag ,
10436 t_INVOCABLE&& invocable,
10437 t_ARG&& arg)
10438: StdOptionalBase(Optional_ImmovableHelper<t_TYPE, t_INVOCABLE, t_ARG>{
10439 std::forward<t_INVOCABLE>(invocable),
10440 std::forward<t_ARG>(arg)})
10441{
10442}
10443#endif
10444
10445template <class t_TYPE>
10446inline
10447Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t, AllocType)
10448{
10450 "Should not be called for non-allocator-aware types");
10451}
10452
10453template <class t_TYPE>
10454inline
10455Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t,
10456 AllocType,
10458{
10460 "Should not be called for non-allocator-aware types");
10461}
10462
10463template <class t_TYPE>
10464template <class t_ANY_TYPE>
10465inline
10466Optional_Base<t_TYPE, false>::Optional_Base(
10468 AllocType,
10469 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
10470 t_ANY_TYPE&&)
10471{
10473 "Should not be called for non-allocator-aware types");
10474}
10475
10476template <class t_TYPE>
10477template <class t_ANY_TYPE>
10478inline
10479Optional_Base<t_TYPE, false>::Optional_Base(
10481 AllocType,
10482 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
10483 const Optional_Base<t_ANY_TYPE>&)
10484{
10486 "Should not be called for non-allocator-aware types");
10487}
10488
10489template <class t_TYPE>
10490template <class t_ANY_TYPE>
10491inline
10492Optional_Base<t_TYPE, false>::Optional_Base(
10494 AllocType,
10495 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
10496 Optional_Base<t_ANY_TYPE>&&)
10497{
10499 "Should not be called for non-allocator-aware types");
10500}
10501
10502template <class t_TYPE>
10503template <class t_ANY_TYPE>
10504inline
10505Optional_Base<t_TYPE, false>::Optional_Base(
10507 AllocType,
10508 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
10509 const std::optional<t_ANY_TYPE>&)
10510{
10512 "Should not be called for non-allocator-aware types");
10513}
10514
10515template <class t_TYPE>
10516template <class t_ANY_TYPE>
10517inline
10518Optional_Base<t_TYPE, false>::Optional_Base(
10520 AllocType,
10521 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
10522 std::optional<t_ANY_TYPE>&&)
10523{
10525 "Should not be called for non-allocator-aware types");
10526}
10527
10528template <class t_TYPE>
10529template <class... t_ARGS>
10530inline
10531Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t,
10532 AllocType,
10534 t_ARGS&&...)
10535{
10537 "Should not be called for non-allocator-aware types");
10538}
10539
10540template <class t_TYPE>
10541template <class t_INIT_LIST_TYPE, class... t_ARGS>
10542inline
10543Optional_Base<t_TYPE, false>::Optional_Base(
10545 AllocType,
10547 std::initializer_list<t_INIT_LIST_TYPE>,
10549{
10551 "Should not be called for non-allocator-aware types");
10552}
10553
10554// PROTECTED MANIPULATORS
10555template <class t_TYPE>
10556template <class t_ANY_TYPE>
10558void Optional_Base<t_TYPE, false>::assignOrEmplace(t_ANY_TYPE&& rhs)
10559{
10560 StdOptionalBase::operator=(std::forward<t_ANY_TYPE>(rhs));
10561}
10562
10563# ifndef BDE_OMIT_INTERNAL_DEPRECATED
10564template <class t_TYPE>
10565t_TYPE& Optional_Base<t_TYPE, false>::dereferenceRaw()
10566{
10567 // This method is provided for the purpose of allowing 'NullableValue' to
10568 // determine the assert level in its value() method. Do not assert here.
10569
10570 return this->operator*();
10571
10572}
10573
10574// PROTECTED ACCESSORS
10575template <class t_TYPE>
10576const t_TYPE& Optional_Base<t_TYPE, false>::dereferenceRaw() const
10577{
10578 // This method is provided for the purpose of allowing 'NullableValue' to
10579 // determine the assert level in its value() method. Do not assert here.
10580
10581 return this->operator*();
10582
10583}
10584# endif // BDE_OMIT_INTERNAL_DEPRECATED
10585
10586# else // BSLSTL_OPTIONAL_USES_STD_ALIASES
10587
10588// ============================================================================
10589// Section: Pre-C++17 Allocator-Unaware 'Optional_Base' Method Definitions
10590// ============================================================================
10591
10592// PROTECTED CREATORS
10593template <class t_TYPE>
10594inline
10595Optional_Base<t_TYPE, false>::Optional_Base()
10596{
10597}
10598
10599template <class t_TYPE>
10600inline
10601Optional_Base<t_TYPE, false>::Optional_Base(bsl::nullopt_t)
10602{
10603}
10604
10605template <class t_TYPE>
10606inline
10607Optional_Base<t_TYPE, false>::Optional_Base(const Optional_Base& original)
10608{
10609 if (original.has_value()) {
10610 emplace(original.value());
10611 }
10612}
10613
10614template <class t_TYPE>
10615inline
10616Optional_Base<t_TYPE, false>::Optional_Base(
10617 BloombergLP::bslmf::MovableRef<Optional_Base> original)
10620{
10621 Optional_Base& lvalue = original;
10622
10623 if (lvalue.has_value()) {
10624 emplace(MoveUtil::move(*lvalue));
10625 }
10626}
10627
10628template <class t_TYPE>
10629template <class t_ANY_TYPE>
10630inline
10631Optional_Base<t_TYPE, false>::Optional_Base(
10632 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
10633 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
10634{
10635 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value));
10636}
10637
10638template <class t_TYPE>
10639template <class t_ANY_TYPE>
10640inline
10641Optional_Base<t_TYPE, false>::Optional_Base(
10642 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
10643 const Optional_Base<t_ANY_TYPE>& original)
10644{
10645 if (original.has_value()) {
10646 emplace(original.value());
10647 }
10648}
10649
10650template <class t_TYPE>
10651template <class t_ANY_TYPE>
10652inline
10653Optional_Base<t_TYPE, false>::Optional_Base(
10654 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
10655 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>) original)
10656{
10657 Optional_Base<t_ANY_TYPE>& lvalue = original;
10658 if (lvalue.has_value()) {
10659 emplace(MoveUtil::move(*lvalue));
10660 }
10661}
10662
10663#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
10664// {{{ BEGIN GENERATED CODE
10665// Command line: sim_cpp11_features.pl bslstl_optional.h
10666#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
10667#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
10668#endif
10669#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_P
10670#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_P BSLSTL_OPTIONAL_VARIADIC_LIMIT
10671#endif
10672#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 0
10673template <class t_TYPE>
10674inline
10675Optional_Base<t_TYPE, false>::Optional_Base(
10677{
10678 emplace();
10679}
10680#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 0
10681
10682#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 1
10683template <class t_TYPE>
10684template <class t_ARGS_01>
10685inline
10686Optional_Base<t_TYPE, false>::Optional_Base(
10688 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
10689{
10690 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
10691}
10692#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 1
10693
10694#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 2
10695template <class t_TYPE>
10696template <class t_ARGS_01,
10697 class t_ARGS_02>
10698inline
10699Optional_Base<t_TYPE, false>::Optional_Base(
10701 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10702 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
10703{
10704 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10705 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
10706}
10707#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 2
10708
10709#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 3
10710template <class t_TYPE>
10711template <class t_ARGS_01,
10712 class t_ARGS_02,
10713 class t_ARGS_03>
10714inline
10715Optional_Base<t_TYPE, false>::Optional_Base(
10717 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10718 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10719 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
10720{
10721 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10722 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10723 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
10724}
10725#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 3
10726
10727#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 4
10728template <class t_TYPE>
10729template <class t_ARGS_01,
10730 class t_ARGS_02,
10731 class t_ARGS_03,
10732 class t_ARGS_04>
10733inline
10734Optional_Base<t_TYPE, false>::Optional_Base(
10736 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10737 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10738 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10739 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
10740{
10741 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10742 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10743 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10744 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
10745}
10746#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 4
10747
10748#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 5
10749template <class t_TYPE>
10750template <class t_ARGS_01,
10751 class t_ARGS_02,
10752 class t_ARGS_03,
10753 class t_ARGS_04,
10754 class t_ARGS_05>
10755inline
10756Optional_Base<t_TYPE, false>::Optional_Base(
10758 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10759 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10760 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10761 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10762 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
10763{
10764 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10765 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10766 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10767 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10768 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
10769}
10770#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 5
10771
10772#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 6
10773template <class t_TYPE>
10774template <class t_ARGS_01,
10775 class t_ARGS_02,
10776 class t_ARGS_03,
10777 class t_ARGS_04,
10778 class t_ARGS_05,
10779 class t_ARGS_06>
10780inline
10781Optional_Base<t_TYPE, false>::Optional_Base(
10783 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10784 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10785 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10786 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10787 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
10788 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
10789{
10790 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10791 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10792 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10793 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10794 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
10795 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
10796}
10797#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 6
10798
10799#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 7
10800template <class t_TYPE>
10801template <class t_ARGS_01,
10802 class t_ARGS_02,
10803 class t_ARGS_03,
10804 class t_ARGS_04,
10805 class t_ARGS_05,
10806 class t_ARGS_06,
10807 class t_ARGS_07>
10808inline
10809Optional_Base<t_TYPE, false>::Optional_Base(
10811 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10812 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10813 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10814 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10815 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
10816 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
10817 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
10818{
10819 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10820 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10821 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10822 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10823 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
10824 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
10825 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
10826}
10827#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 7
10828
10829#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 8
10830template <class t_TYPE>
10831template <class t_ARGS_01,
10832 class t_ARGS_02,
10833 class t_ARGS_03,
10834 class t_ARGS_04,
10835 class t_ARGS_05,
10836 class t_ARGS_06,
10837 class t_ARGS_07,
10838 class t_ARGS_08>
10839inline
10840Optional_Base<t_TYPE, false>::Optional_Base(
10842 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10843 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10844 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10845 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10846 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
10847 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
10848 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
10849 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
10850{
10851 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10852 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10853 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10854 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10855 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
10856 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
10857 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
10858 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
10859}
10860#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 8
10861
10862#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 9
10863template <class t_TYPE>
10864template <class t_ARGS_01,
10865 class t_ARGS_02,
10866 class t_ARGS_03,
10867 class t_ARGS_04,
10868 class t_ARGS_05,
10869 class t_ARGS_06,
10870 class t_ARGS_07,
10871 class t_ARGS_08,
10872 class t_ARGS_09>
10873inline
10874Optional_Base<t_TYPE, false>::Optional_Base(
10876 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10877 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10878 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10879 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10880 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
10881 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
10882 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
10883 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
10884 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
10885{
10886 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10887 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10888 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10889 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10890 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
10891 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
10892 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
10893 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
10894 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
10895}
10896#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 9
10897
10898#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 10
10899template <class t_TYPE>
10900template <class t_ARGS_01,
10901 class t_ARGS_02,
10902 class t_ARGS_03,
10903 class t_ARGS_04,
10904 class t_ARGS_05,
10905 class t_ARGS_06,
10906 class t_ARGS_07,
10907 class t_ARGS_08,
10908 class t_ARGS_09,
10909 class t_ARGS_10>
10910inline
10911Optional_Base<t_TYPE, false>::Optional_Base(
10913 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10914 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10915 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
10916 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
10917 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
10918 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
10919 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
10920 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
10921 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
10922 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
10923{
10924 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10925 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10926 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
10927 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
10928 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
10929 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
10930 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
10931 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
10932 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
10933 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
10934}
10935#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 10
10936
10937
10938# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
10939#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 0
10940template <class t_TYPE>
10941template <class t_INIT_LIST_TYPE>
10942inline
10943Optional_Base<t_TYPE, false>::Optional_Base(
10945 std::initializer_list<t_INIT_LIST_TYPE> il)
10946{
10947 emplace(il);
10948}
10949#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 0
10950
10951#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 1
10952template <class t_TYPE>
10953template <class t_INIT_LIST_TYPE, class t_ARGS_01>
10954inline
10955Optional_Base<t_TYPE, false>::Optional_Base(
10957 std::initializer_list<t_INIT_LIST_TYPE> il,
10958 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
10959{
10960 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
10961}
10962#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 1
10963
10964#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 2
10965template <class t_TYPE>
10966template <class t_INIT_LIST_TYPE, class t_ARGS_01,
10967 class t_ARGS_02>
10968inline
10969Optional_Base<t_TYPE, false>::Optional_Base(
10971 std::initializer_list<t_INIT_LIST_TYPE> il,
10972 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10973 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
10974{
10975 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10976 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
10977}
10978#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 2
10979
10980#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 3
10981template <class t_TYPE>
10982template <class t_INIT_LIST_TYPE, class t_ARGS_01,
10983 class t_ARGS_02,
10984 class t_ARGS_03>
10985inline
10986Optional_Base<t_TYPE, false>::Optional_Base(
10988 std::initializer_list<t_INIT_LIST_TYPE> il,
10989 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
10990 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
10991 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
10992{
10993 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
10994 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
10995 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
10996}
10997#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 3
10998
10999#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 4
11000template <class t_TYPE>
11001template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11002 class t_ARGS_02,
11003 class t_ARGS_03,
11004 class t_ARGS_04>
11005inline
11006Optional_Base<t_TYPE, false>::Optional_Base(
11008 std::initializer_list<t_INIT_LIST_TYPE> il,
11009 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11010 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11011 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11012 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
11013{
11014 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11015 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11016 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11017 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
11018}
11019#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 4
11020
11021#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 5
11022template <class t_TYPE>
11023template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11024 class t_ARGS_02,
11025 class t_ARGS_03,
11026 class t_ARGS_04,
11027 class t_ARGS_05>
11028inline
11029Optional_Base<t_TYPE, false>::Optional_Base(
11031 std::initializer_list<t_INIT_LIST_TYPE> il,
11032 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11033 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11034 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11035 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11036 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
11037{
11038 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11039 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11040 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11041 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11042 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
11043}
11044#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 5
11045
11046#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 6
11047template <class t_TYPE>
11048template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11049 class t_ARGS_02,
11050 class t_ARGS_03,
11051 class t_ARGS_04,
11052 class t_ARGS_05,
11053 class t_ARGS_06>
11054inline
11055Optional_Base<t_TYPE, false>::Optional_Base(
11057 std::initializer_list<t_INIT_LIST_TYPE> il,
11058 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11059 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11060 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11061 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11062 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
11063 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
11064{
11065 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11066 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11067 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11068 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11069 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
11070 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
11071}
11072#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 6
11073
11074#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 7
11075template <class t_TYPE>
11076template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11077 class t_ARGS_02,
11078 class t_ARGS_03,
11079 class t_ARGS_04,
11080 class t_ARGS_05,
11081 class t_ARGS_06,
11082 class t_ARGS_07>
11083inline
11084Optional_Base<t_TYPE, false>::Optional_Base(
11086 std::initializer_list<t_INIT_LIST_TYPE> il,
11087 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11088 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11089 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11090 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11091 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
11092 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
11093 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
11094{
11095 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11096 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11097 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11098 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11099 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
11100 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
11101 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
11102}
11103#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 7
11104
11105#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 8
11106template <class t_TYPE>
11107template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11108 class t_ARGS_02,
11109 class t_ARGS_03,
11110 class t_ARGS_04,
11111 class t_ARGS_05,
11112 class t_ARGS_06,
11113 class t_ARGS_07,
11114 class t_ARGS_08>
11115inline
11116Optional_Base<t_TYPE, false>::Optional_Base(
11118 std::initializer_list<t_INIT_LIST_TYPE> il,
11119 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11120 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11121 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11122 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11123 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
11124 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
11125 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
11126 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
11127{
11128 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11129 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11130 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11131 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11132 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
11133 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
11134 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
11135 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
11136}
11137#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 8
11138
11139#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 9
11140template <class t_TYPE>
11141template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11142 class t_ARGS_02,
11143 class t_ARGS_03,
11144 class t_ARGS_04,
11145 class t_ARGS_05,
11146 class t_ARGS_06,
11147 class t_ARGS_07,
11148 class t_ARGS_08,
11149 class t_ARGS_09>
11150inline
11151Optional_Base<t_TYPE, false>::Optional_Base(
11153 std::initializer_list<t_INIT_LIST_TYPE> il,
11154 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11155 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11156 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11157 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11158 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
11159 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
11160 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
11161 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
11162 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
11163{
11164 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11165 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11166 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11167 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11168 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
11169 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
11170 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
11171 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
11172 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
11173}
11174#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 9
11175
11176#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 10
11177template <class t_TYPE>
11178template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11179 class t_ARGS_02,
11180 class t_ARGS_03,
11181 class t_ARGS_04,
11182 class t_ARGS_05,
11183 class t_ARGS_06,
11184 class t_ARGS_07,
11185 class t_ARGS_08,
11186 class t_ARGS_09,
11187 class t_ARGS_10>
11188inline
11189Optional_Base<t_TYPE, false>::Optional_Base(
11191 std::initializer_list<t_INIT_LIST_TYPE> il,
11192 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11193 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11194 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
11195 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
11196 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
11197 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
11198 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
11199 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
11200 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
11201 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
11202{
11203 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11204 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11205 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
11206 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
11207 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
11208 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
11209 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
11210 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
11211 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
11212 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
11213}
11214#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_P >= 10
11215
11216# endif
11217#else
11218// The generated code below is a workaround for the absence of perfect
11219// forwarding in some compilers.
11220template <class t_TYPE>
11221template <class... t_ARGS>
11222inline
11223Optional_Base<t_TYPE, false>::Optional_Base(
11225 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
11226{
11227 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
11228}
11229
11230# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
11231template <class t_TYPE>
11232template <class t_INIT_LIST_TYPE, class... t_ARGS>
11233inline
11234Optional_Base<t_TYPE, false>::Optional_Base(
11236 std::initializer_list<t_INIT_LIST_TYPE> il,
11237 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
11238{
11239 emplace(il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
11240}
11241# endif
11242// }}} END GENERATED CODE
11243#endif
11244
11245template <class t_TYPE>
11246inline
11247Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t, AllocType)
11248{
11250 "Should not be called for non-allocator-aware types");
11251}
11252
11253template <class t_TYPE>
11254inline
11255Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t,
11256 AllocType,
11258{
11260 "Should not be called for non-allocator-aware types");
11261}
11262
11263template <class t_TYPE>
11264inline
11265Optional_Base<t_TYPE, false>::Optional_Base(bsl::allocator_arg_t,
11266 AllocType,
11267 const Optional_Base&)
11268{
11270 "Should not be called for non-allocator-aware types");
11271}
11272
11273template <class t_TYPE>
11274inline
11275Optional_Base<t_TYPE, false>::Optional_Base(
11277 AllocType,
11278 BloombergLP::bslmf::MovableRef<Optional_Base>)
11279{
11281 "Should not be called for non-allocator-aware types");
11282}
11283
11284template <class t_TYPE>
11285template <class t_ANY_TYPE>
11286inline
11287Optional_Base<t_TYPE, false>::Optional_Base(
11289 AllocType,
11290 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
11292{
11294 "Should not be called for non-allocator-aware types");
11295}
11296
11297template <class t_TYPE>
11298template <class t_ANY_TYPE>
11299inline
11300Optional_Base<t_TYPE, false>::Optional_Base(
11302 AllocType,
11303 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
11304 const Optional_Base<t_ANY_TYPE>&)
11305{
11307 "Should not be called for non-allocator-aware types");
11308}
11309
11310template <class t_TYPE>
11311template <class t_ANY_TYPE>
11312inline
11313Optional_Base<t_TYPE, false>::Optional_Base(
11315 AllocType,
11316 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
11317 BSLMF_MOVABLEREF_DEDUCE(Optional_Base<t_ANY_TYPE>))
11318{
11320 "Should not be called for non-allocator-aware types");
11321}
11322
11323#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
11324// {{{ BEGIN GENERATED CODE
11325// Command line: sim_cpp11_features.pl bslstl_optional.h
11326#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
11327#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
11328#endif
11329#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q
11330#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q BSLSTL_OPTIONAL_VARIADIC_LIMIT
11331#endif
11332#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 0
11333template <class t_TYPE>
11334inline
11335Optional_Base<t_TYPE, false>::Optional_Base(
11337 AllocType,
11339{
11341 "Should not be called for non-allocator-aware types");
11342}
11343#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 0
11344
11345#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 1
11346template <class t_TYPE>
11347template <class t_ARGS_01>
11348inline
11349Optional_Base<t_TYPE, false>::Optional_Base(
11351 AllocType,
11354{
11356 "Should not be called for non-allocator-aware types");
11357}
11358#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 1
11359
11360#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 2
11361template <class t_TYPE>
11362template <class t_ARGS_01,
11363 class t_ARGS_02>
11364inline
11365Optional_Base<t_TYPE, false>::Optional_Base(
11367 AllocType,
11371{
11373 "Should not be called for non-allocator-aware types");
11374}
11375#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 2
11376
11377#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 3
11378template <class t_TYPE>
11379template <class t_ARGS_01,
11380 class t_ARGS_02,
11381 class t_ARGS_03>
11382inline
11383Optional_Base<t_TYPE, false>::Optional_Base(
11385 AllocType,
11390{
11392 "Should not be called for non-allocator-aware types");
11393}
11394#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 3
11395
11396#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 4
11397template <class t_TYPE>
11398template <class t_ARGS_01,
11399 class t_ARGS_02,
11400 class t_ARGS_03,
11401 class t_ARGS_04>
11402inline
11403Optional_Base<t_TYPE, false>::Optional_Base(
11405 AllocType,
11411{
11413 "Should not be called for non-allocator-aware types");
11414}
11415#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 4
11416
11417#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 5
11418template <class t_TYPE>
11419template <class t_ARGS_01,
11420 class t_ARGS_02,
11421 class t_ARGS_03,
11422 class t_ARGS_04,
11423 class t_ARGS_05>
11424inline
11425Optional_Base<t_TYPE, false>::Optional_Base(
11427 AllocType,
11434{
11436 "Should not be called for non-allocator-aware types");
11437}
11438#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 5
11439
11440#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 6
11441template <class t_TYPE>
11442template <class t_ARGS_01,
11443 class t_ARGS_02,
11444 class t_ARGS_03,
11445 class t_ARGS_04,
11446 class t_ARGS_05,
11447 class t_ARGS_06>
11448inline
11449Optional_Base<t_TYPE, false>::Optional_Base(
11451 AllocType,
11459{
11461 "Should not be called for non-allocator-aware types");
11462}
11463#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 6
11464
11465#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 7
11466template <class t_TYPE>
11467template <class t_ARGS_01,
11468 class t_ARGS_02,
11469 class t_ARGS_03,
11470 class t_ARGS_04,
11471 class t_ARGS_05,
11472 class t_ARGS_06,
11473 class t_ARGS_07>
11474inline
11475Optional_Base<t_TYPE, false>::Optional_Base(
11477 AllocType,
11486{
11488 "Should not be called for non-allocator-aware types");
11489}
11490#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 7
11491
11492#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 8
11493template <class t_TYPE>
11494template <class t_ARGS_01,
11495 class t_ARGS_02,
11496 class t_ARGS_03,
11497 class t_ARGS_04,
11498 class t_ARGS_05,
11499 class t_ARGS_06,
11500 class t_ARGS_07,
11501 class t_ARGS_08>
11502inline
11503Optional_Base<t_TYPE, false>::Optional_Base(
11505 AllocType,
11515{
11517 "Should not be called for non-allocator-aware types");
11518}
11519#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 8
11520
11521#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 9
11522template <class t_TYPE>
11523template <class t_ARGS_01,
11524 class t_ARGS_02,
11525 class t_ARGS_03,
11526 class t_ARGS_04,
11527 class t_ARGS_05,
11528 class t_ARGS_06,
11529 class t_ARGS_07,
11530 class t_ARGS_08,
11531 class t_ARGS_09>
11532inline
11533Optional_Base<t_TYPE, false>::Optional_Base(
11535 AllocType,
11546{
11548 "Should not be called for non-allocator-aware types");
11549}
11550#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 9
11551
11552#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 10
11553template <class t_TYPE>
11554template <class t_ARGS_01,
11555 class t_ARGS_02,
11556 class t_ARGS_03,
11557 class t_ARGS_04,
11558 class t_ARGS_05,
11559 class t_ARGS_06,
11560 class t_ARGS_07,
11561 class t_ARGS_08,
11562 class t_ARGS_09,
11563 class t_ARGS_10>
11564inline
11565Optional_Base<t_TYPE, false>::Optional_Base(
11567 AllocType,
11579{
11581 "Should not be called for non-allocator-aware types");
11582}
11583#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 10
11584
11585
11586# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
11587#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 0
11588template <class t_TYPE>
11589template <class t_INIT_LIST_TYPE>
11590inline
11591Optional_Base<t_TYPE, false>::Optional_Base(
11593 AllocType,
11595 std::initializer_list<t_INIT_LIST_TYPE>)
11596{
11598 "Should not be called for non-allocator-aware types");
11599}
11600#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 0
11601
11602#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 1
11603template <class t_TYPE>
11604template <class t_INIT_LIST_TYPE, class t_ARGS_01>
11605inline
11606Optional_Base<t_TYPE, false>::Optional_Base(
11608 AllocType,
11610 std::initializer_list<t_INIT_LIST_TYPE>,
11612{
11614 "Should not be called for non-allocator-aware types");
11615}
11616#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 1
11617
11618#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 2
11619template <class t_TYPE>
11620template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11621 class t_ARGS_02>
11622inline
11623Optional_Base<t_TYPE, false>::Optional_Base(
11625 AllocType,
11627 std::initializer_list<t_INIT_LIST_TYPE>,
11630{
11632 "Should not be called for non-allocator-aware types");
11633}
11634#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 2
11635
11636#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 3
11637template <class t_TYPE>
11638template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11639 class t_ARGS_02,
11640 class t_ARGS_03>
11641inline
11642Optional_Base<t_TYPE, false>::Optional_Base(
11644 AllocType,
11646 std::initializer_list<t_INIT_LIST_TYPE>,
11650{
11652 "Should not be called for non-allocator-aware types");
11653}
11654#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 3
11655
11656#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 4
11657template <class t_TYPE>
11658template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11659 class t_ARGS_02,
11660 class t_ARGS_03,
11661 class t_ARGS_04>
11662inline
11663Optional_Base<t_TYPE, false>::Optional_Base(
11665 AllocType,
11667 std::initializer_list<t_INIT_LIST_TYPE>,
11672{
11674 "Should not be called for non-allocator-aware types");
11675}
11676#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 4
11677
11678#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 5
11679template <class t_TYPE>
11680template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11681 class t_ARGS_02,
11682 class t_ARGS_03,
11683 class t_ARGS_04,
11684 class t_ARGS_05>
11685inline
11686Optional_Base<t_TYPE, false>::Optional_Base(
11688 AllocType,
11690 std::initializer_list<t_INIT_LIST_TYPE>,
11696{
11698 "Should not be called for non-allocator-aware types");
11699}
11700#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 5
11701
11702#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 6
11703template <class t_TYPE>
11704template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11705 class t_ARGS_02,
11706 class t_ARGS_03,
11707 class t_ARGS_04,
11708 class t_ARGS_05,
11709 class t_ARGS_06>
11710inline
11711Optional_Base<t_TYPE, false>::Optional_Base(
11713 AllocType,
11715 std::initializer_list<t_INIT_LIST_TYPE>,
11722{
11724 "Should not be called for non-allocator-aware types");
11725}
11726#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 6
11727
11728#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 7
11729template <class t_TYPE>
11730template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11731 class t_ARGS_02,
11732 class t_ARGS_03,
11733 class t_ARGS_04,
11734 class t_ARGS_05,
11735 class t_ARGS_06,
11736 class t_ARGS_07>
11737inline
11738Optional_Base<t_TYPE, false>::Optional_Base(
11740 AllocType,
11742 std::initializer_list<t_INIT_LIST_TYPE>,
11750{
11752 "Should not be called for non-allocator-aware types");
11753}
11754#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 7
11755
11756#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 8
11757template <class t_TYPE>
11758template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11759 class t_ARGS_02,
11760 class t_ARGS_03,
11761 class t_ARGS_04,
11762 class t_ARGS_05,
11763 class t_ARGS_06,
11764 class t_ARGS_07,
11765 class t_ARGS_08>
11766inline
11767Optional_Base<t_TYPE, false>::Optional_Base(
11769 AllocType,
11771 std::initializer_list<t_INIT_LIST_TYPE>,
11780{
11782 "Should not be called for non-allocator-aware types");
11783}
11784#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 8
11785
11786#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 9
11787template <class t_TYPE>
11788template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11789 class t_ARGS_02,
11790 class t_ARGS_03,
11791 class t_ARGS_04,
11792 class t_ARGS_05,
11793 class t_ARGS_06,
11794 class t_ARGS_07,
11795 class t_ARGS_08,
11796 class t_ARGS_09>
11797inline
11798Optional_Base<t_TYPE, false>::Optional_Base(
11800 AllocType,
11802 std::initializer_list<t_INIT_LIST_TYPE>,
11812{
11814 "Should not be called for non-allocator-aware types");
11815}
11816#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 9
11817
11818#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 10
11819template <class t_TYPE>
11820template <class t_INIT_LIST_TYPE, class t_ARGS_01,
11821 class t_ARGS_02,
11822 class t_ARGS_03,
11823 class t_ARGS_04,
11824 class t_ARGS_05,
11825 class t_ARGS_06,
11826 class t_ARGS_07,
11827 class t_ARGS_08,
11828 class t_ARGS_09,
11829 class t_ARGS_10>
11830inline
11831Optional_Base<t_TYPE, false>::Optional_Base(
11833 AllocType,
11835 std::initializer_list<t_INIT_LIST_TYPE>,
11846{
11848 "Should not be called for non-allocator-aware types");
11849}
11850#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_Q >= 10
11851
11852# endif
11853#else
11854// The generated code below is a workaround for the absence of perfect
11855// forwarding in some compilers.
11856template <class t_TYPE>
11857template <class... t_ARGS>
11858inline
11859Optional_Base<t_TYPE, false>::Optional_Base(
11861 AllocType,
11864{
11866 "Should not be called for non-allocator-aware types");
11867}
11868
11869# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
11870template <class t_TYPE>
11871template <class t_INIT_LIST_TYPE, class... t_ARGS>
11872inline
11873Optional_Base<t_TYPE, false>::Optional_Base(
11875 AllocType,
11877 std::initializer_list<t_INIT_LIST_TYPE>,
11879{
11881 "Should not be called for non-allocator-aware types");
11882}
11883# endif
11884// }}} END GENERATED CODE
11885#endif
11886
11887// PROTECTED MANIPULATORS
11888template <class t_TYPE>
11889template <class t_ANY_TYPE>
11890void Optional_Base<t_TYPE, false>::assignOrEmplace(
11891 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) rhs)
11892{
11893 if (has_value()) {
11894 d_value.value() = BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, rhs);
11895 } else {
11896 emplace(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, rhs));
11897 }
11898}
11899
11900# ifndef BDE_OMIT_INTERNAL_DEPRECATED
11901template <class t_TYPE>
11902t_TYPE& Optional_Base<t_TYPE, false>::dereferenceRaw()
11903{
11904 // This method is provided for the purpose of allowing 'NullableValue' to
11905 // determine the assert level in its value() method. Do not assert here.
11906
11907 return d_value.value();
11908
11909}
11910
11911// PROTECTED ACCESORS
11912template <class t_TYPE>
11913const t_TYPE& Optional_Base<t_TYPE, false>::dereferenceRaw() const
11914{
11915 // This method is provided for the purpose of allowing 'NullableValue' to
11916 // determine the assert level in its value() method. Do not assert here.
11917
11918 return d_value.value();
11919
11920}
11921# endif // BDE_OMIT_INTERNAL_DEPRECATED
11922
11923// MANIPULATORS
11924#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
11925// {{{ BEGIN GENERATED CODE
11926// Command line: sim_cpp11_features.pl bslstl_optional.h
11927#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
11928#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
11929#endif
11930#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_R
11931#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_R BSLSTL_OPTIONAL_VARIADIC_LIMIT
11932#endif
11933#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 0
11934template <class t_TYPE>
11935inline
11936t_TYPE&
11937Optional_Base<t_TYPE, false>::emplace(
11938 )
11939{
11940 return d_value.emplace(NULL);
11941}
11942#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 0
11943
11944#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 1
11945template <class t_TYPE>
11946template <class t_ARGS_01>
11947inline
11948t_TYPE&
11949Optional_Base<t_TYPE, false>::emplace(
11950 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
11951{
11952 return d_value.emplace(NULL,
11953 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
11954}
11955#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 1
11956
11957#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 2
11958template <class t_TYPE>
11959template <class t_ARGS_01,
11960 class t_ARGS_02>
11961inline
11962t_TYPE&
11963Optional_Base<t_TYPE, false>::emplace(
11964 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11965 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
11966{
11967 return d_value.emplace(NULL,
11968 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11969 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
11970}
11971#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 2
11972
11973#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 3
11974template <class t_TYPE>
11975template <class t_ARGS_01,
11976 class t_ARGS_02,
11977 class t_ARGS_03>
11978inline
11979t_TYPE&
11980Optional_Base<t_TYPE, false>::emplace(
11981 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
11982 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
11983 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
11984{
11985 return d_value.emplace(NULL,
11986 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
11987 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
11988 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
11989}
11990#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 3
11991
11992#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 4
11993template <class t_TYPE>
11994template <class t_ARGS_01,
11995 class t_ARGS_02,
11996 class t_ARGS_03,
11997 class t_ARGS_04>
11998inline
11999t_TYPE&
12000Optional_Base<t_TYPE, false>::emplace(
12001 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12002 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12003 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12004 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
12005{
12006 return d_value.emplace(NULL,
12007 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12008 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12009 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12010 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
12011}
12012#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 4
12013
12014#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 5
12015template <class t_TYPE>
12016template <class t_ARGS_01,
12017 class t_ARGS_02,
12018 class t_ARGS_03,
12019 class t_ARGS_04,
12020 class t_ARGS_05>
12021inline
12022t_TYPE&
12023Optional_Base<t_TYPE, false>::emplace(
12024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12026 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12027 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12028 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
12029{
12030 return d_value.emplace(NULL,
12031 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12032 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12033 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12034 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12035 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
12036}
12037#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 5
12038
12039#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 6
12040template <class t_TYPE>
12041template <class t_ARGS_01,
12042 class t_ARGS_02,
12043 class t_ARGS_03,
12044 class t_ARGS_04,
12045 class t_ARGS_05,
12046 class t_ARGS_06>
12047inline
12048t_TYPE&
12049Optional_Base<t_TYPE, false>::emplace(
12050 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12051 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12052 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12053 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12054 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12055 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
12056{
12057 return d_value.emplace(NULL,
12058 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12059 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12060 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12061 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12062 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12063 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
12064}
12065#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 6
12066
12067#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 7
12068template <class t_TYPE>
12069template <class t_ARGS_01,
12070 class t_ARGS_02,
12071 class t_ARGS_03,
12072 class t_ARGS_04,
12073 class t_ARGS_05,
12074 class t_ARGS_06,
12075 class t_ARGS_07>
12076inline
12077t_TYPE&
12078Optional_Base<t_TYPE, false>::emplace(
12079 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12080 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12081 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12082 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12083 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12084 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12085 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
12086{
12087 return d_value.emplace(NULL,
12088 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12089 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12090 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12091 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12092 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12093 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12094 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
12095}
12096#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 7
12097
12098#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 8
12099template <class t_TYPE>
12100template <class t_ARGS_01,
12101 class t_ARGS_02,
12102 class t_ARGS_03,
12103 class t_ARGS_04,
12104 class t_ARGS_05,
12105 class t_ARGS_06,
12106 class t_ARGS_07,
12107 class t_ARGS_08>
12108inline
12109t_TYPE&
12110Optional_Base<t_TYPE, false>::emplace(
12111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12112 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12113 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12114 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12115 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12116 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12117 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12118 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
12119{
12120 return d_value.emplace(NULL,
12121 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12122 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12123 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12124 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12125 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12126 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12127 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12128 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
12129}
12130#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 8
12131
12132#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 9
12133template <class t_TYPE>
12134template <class t_ARGS_01,
12135 class t_ARGS_02,
12136 class t_ARGS_03,
12137 class t_ARGS_04,
12138 class t_ARGS_05,
12139 class t_ARGS_06,
12140 class t_ARGS_07,
12141 class t_ARGS_08,
12142 class t_ARGS_09>
12143inline
12144t_TYPE&
12145Optional_Base<t_TYPE, false>::emplace(
12146 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12147 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12148 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12149 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12150 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12151 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12152 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12153 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
12154 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
12155{
12156 return d_value.emplace(NULL,
12157 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12158 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12159 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12160 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12161 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12162 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12163 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12164 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
12165 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
12166}
12167#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 9
12168
12169#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 10
12170template <class t_TYPE>
12171template <class t_ARGS_01,
12172 class t_ARGS_02,
12173 class t_ARGS_03,
12174 class t_ARGS_04,
12175 class t_ARGS_05,
12176 class t_ARGS_06,
12177 class t_ARGS_07,
12178 class t_ARGS_08,
12179 class t_ARGS_09,
12180 class t_ARGS_10>
12181inline
12182t_TYPE&
12183Optional_Base<t_TYPE, false>::emplace(
12184 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12185 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12186 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12187 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12188 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12189 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12190 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12191 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
12192 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
12193 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
12194{
12195 return d_value.emplace(NULL,
12196 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12197 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12198 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12199 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12200 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12201 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12202 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12203 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
12204 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
12205 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
12206}
12207#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 10
12208
12209
12210# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
12211#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 0
12212template <class t_TYPE>
12213template <class t_INIT_LIST_TYPE>
12214t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12215 std::initializer_list<t_INIT_LIST_TYPE> il)
12216{
12217 return d_value.emplace(
12218 NULL, il);
12219}
12220#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 0
12221
12222#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 1
12223template <class t_TYPE>
12224template <class t_INIT_LIST_TYPE, class t_ARGS_01>
12225t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12226 std::initializer_list<t_INIT_LIST_TYPE> il,
12227 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
12228{
12229 return d_value.emplace(
12230 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
12231}
12232#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 1
12233
12234#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 2
12235template <class t_TYPE>
12236template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12237 class t_ARGS_02>
12238t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12239 std::initializer_list<t_INIT_LIST_TYPE> il,
12240 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12241 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
12242{
12243 return d_value.emplace(
12244 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12245 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
12246}
12247#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 2
12248
12249#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 3
12250template <class t_TYPE>
12251template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12252 class t_ARGS_02,
12253 class t_ARGS_03>
12254t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12255 std::initializer_list<t_INIT_LIST_TYPE> il,
12256 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12257 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12258 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
12259{
12260 return d_value.emplace(
12261 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12262 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12263 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
12264}
12265#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 3
12266
12267#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 4
12268template <class t_TYPE>
12269template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12270 class t_ARGS_02,
12271 class t_ARGS_03,
12272 class t_ARGS_04>
12273t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12274 std::initializer_list<t_INIT_LIST_TYPE> il,
12275 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12276 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12277 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12278 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
12279{
12280 return d_value.emplace(
12281 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12282 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12283 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12284 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
12285}
12286#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 4
12287
12288#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 5
12289template <class t_TYPE>
12290template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12291 class t_ARGS_02,
12292 class t_ARGS_03,
12293 class t_ARGS_04,
12294 class t_ARGS_05>
12295t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12296 std::initializer_list<t_INIT_LIST_TYPE> il,
12297 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12298 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12299 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12300 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12301 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
12302{
12303 return d_value.emplace(
12304 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12305 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12306 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12307 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12308 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
12309}
12310#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 5
12311
12312#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 6
12313template <class t_TYPE>
12314template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12315 class t_ARGS_02,
12316 class t_ARGS_03,
12317 class t_ARGS_04,
12318 class t_ARGS_05,
12319 class t_ARGS_06>
12320t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12321 std::initializer_list<t_INIT_LIST_TYPE> il,
12322 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12323 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12324 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12325 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12326 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12327 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
12328{
12329 return d_value.emplace(
12330 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12331 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12332 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12333 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12334 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12335 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
12336}
12337#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 6
12338
12339#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 7
12340template <class t_TYPE>
12341template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12342 class t_ARGS_02,
12343 class t_ARGS_03,
12344 class t_ARGS_04,
12345 class t_ARGS_05,
12346 class t_ARGS_06,
12347 class t_ARGS_07>
12348t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12349 std::initializer_list<t_INIT_LIST_TYPE> il,
12350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12353 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
12357{
12358 return d_value.emplace(
12359 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12360 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12361 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12362 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12363 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12364 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12365 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
12366}
12367#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 7
12368
12369#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 8
12370template <class t_TYPE>
12371template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12372 class t_ARGS_02,
12373 class t_ARGS_03,
12374 class t_ARGS_04,
12375 class t_ARGS_05,
12376 class t_ARGS_06,
12377 class t_ARGS_07,
12378 class t_ARGS_08>
12379t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12380 std::initializer_list<t_INIT_LIST_TYPE> il,
12381 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12382 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12383 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12384 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12385 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12386 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12387 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12388 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
12389{
12390 return d_value.emplace(
12391 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12392 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12393 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12394 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12395 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12396 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12397 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12398 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
12399}
12400#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 8
12401
12402#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 9
12403template <class t_TYPE>
12404template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12405 class t_ARGS_02,
12406 class t_ARGS_03,
12407 class t_ARGS_04,
12408 class t_ARGS_05,
12409 class t_ARGS_06,
12410 class t_ARGS_07,
12411 class t_ARGS_08,
12412 class t_ARGS_09>
12413t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12414 std::initializer_list<t_INIT_LIST_TYPE> il,
12415 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12416 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12417 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12418 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12419 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12420 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12421 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12422 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
12423 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
12424{
12425 return d_value.emplace(
12426 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12427 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12428 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12429 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12430 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12431 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12432 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12433 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
12434 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
12435}
12436#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 9
12437
12438#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 10
12439template <class t_TYPE>
12440template <class t_INIT_LIST_TYPE, class t_ARGS_01,
12441 class t_ARGS_02,
12442 class t_ARGS_03,
12443 class t_ARGS_04,
12444 class t_ARGS_05,
12445 class t_ARGS_06,
12446 class t_ARGS_07,
12447 class t_ARGS_08,
12448 class t_ARGS_09,
12449 class t_ARGS_10>
12450t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12451 std::initializer_list<t_INIT_LIST_TYPE> il,
12452 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
12453 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
12454 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
12455 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
12456 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
12457 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
12458 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
12459 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
12460 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
12461 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
12462{
12463 return d_value.emplace(
12464 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
12465 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
12466 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
12467 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
12468 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
12469 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
12470 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
12471 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
12472 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
12473 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
12474}
12475#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_R >= 10
12476
12477# endif
12478#else
12479// The generated code below is a workaround for the absence of perfect
12480// forwarding in some compilers.
12481template <class t_TYPE>
12482template <class... t_ARGS>
12483inline
12484t_TYPE&
12485Optional_Base<t_TYPE, false>::emplace(
12486 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
12487{
12488 return d_value.emplace(NULL,
12489 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
12490}
12491
12492# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
12493template <class t_TYPE>
12494template <class t_INIT_LIST_TYPE, class... t_ARGS>
12495t_TYPE& Optional_Base<t_TYPE, false>::emplace(
12496 std::initializer_list<t_INIT_LIST_TYPE> il,
12497 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
12498{
12499 return d_value.emplace(
12500 NULL, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
12501}
12502# endif
12503// }}} END GENERATED CODE
12504#endif
12505
12506template <class t_TYPE>
12507inline
12508void Optional_Base<t_TYPE, false>::reset() BSLS_KEYWORD_NOEXCEPT
12509{
12510 d_value.reset();
12511}
12512
12513template <class t_TYPE>
12514void Optional_Base<t_TYPE, false>::swap(Optional_Base& other)
12517 bsl::is_nothrow_swappable<t_TYPE>::value)
12518{
12519 if (this->has_value() && other.has_value()) {
12520 BloombergLP::bslalg::SwapUtil::swap(
12521 BSLS_UTIL_ADDRESSOF(d_value.value()),
12522 BSLS_UTIL_ADDRESSOF(*other));
12523 }
12524 else if (this->has_value()) {
12525 other.emplace(MoveUtil::move(d_value.value()));
12526 this->reset();
12527 }
12528 else if (other.has_value()) {
12529 this->emplace(MoveUtil::move(*other));
12530 other.reset();
12531 }
12532}
12533
12534# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12535template <class t_TYPE>
12536inline
12537t_TYPE& Optional_Base<t_TYPE, false>::value() &
12538{
12539 if (!has_value())
12540 BSLS_THROW(bsl::bad_optional_access());
12541
12542 return d_value.value();
12543}
12544template <class t_TYPE>
12545inline
12546t_TYPE&&
12547Optional_Base<t_TYPE, false>::value() &&
12548{
12549 if (!has_value())
12550 BSLS_THROW(bsl::bad_optional_access());
12551
12552 return std::move(d_value.value());
12553}
12554
12555# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12556template <class t_TYPE>
12557inline
12558t_TYPE& Optional_Base<t_TYPE, false>::value()
12559{
12560 if (!has_value())
12561 BSLS_THROW(bsl::bad_optional_access());
12562
12563 return d_value.value();
12564}
12565
12566# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
12567
12568# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12569template <class t_TYPE>
12570template <class t_ANY_TYPE>
12571inline
12572t_TYPE
12573Optional_Base<t_TYPE, false>::value_or(t_ANY_TYPE&& value) &&
12574{
12575 if (has_value()) {
12576 return t_TYPE(std::move(d_value.value())); // RETURN
12577 }
12578 else {
12579 return t_TYPE(std::forward<t_ANY_TYPE>(value)); // RETURN
12580 }
12581}
12582# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12583
12584template <class t_TYPE>
12585inline
12586Optional_Base<t_TYPE, false>&
12587Optional_Base<t_TYPE, false>::operator=(const Optional_Base& rhs)
12588{
12589 if (rhs.has_value()) {
12590 if (this->has_value()) {
12591 d_value.value() = *rhs;
12592 }
12593 else {
12594 emplace(*rhs);
12595 }
12596 }
12597 else {
12598 reset();
12599 }
12600 return *this;
12601}
12602
12603template <class t_TYPE>
12604inline
12605Optional_Base<t_TYPE, false>&
12606Optional_Base<t_TYPE, false>::operator=(
12607 BloombergLP::bslmf::MovableRef<Optional_Base> rhs)
12608{
12609 Optional_Base& lvalue = rhs;
12610 if (lvalue.has_value()) {
12611 if (this->has_value()) {
12612 d_value.value() = MoveUtil::move(*lvalue);
12613 }
12614 else {
12615 emplace(MoveUtil::move(*lvalue));
12616 }
12617 }
12618 else {
12619 reset();
12620 }
12621 return *this;
12622}
12623
12624# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12625template <class t_TYPE>
12626inline
12627t_TYPE& Optional_Base<t_TYPE, false>::operator*() &
12628{
12629 BSLS_ASSERT(has_value());
12630
12631 return d_value.value();
12632}
12633
12634template <class t_TYPE>
12635inline
12636t_TYPE&& Optional_Base<t_TYPE, false>::operator*() &&
12637{
12638 BSLS_ASSERT(has_value());
12639
12640 return std::move(d_value.value());
12641}
12642# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12643template <class t_TYPE>
12644inline
12645t_TYPE& Optional_Base<t_TYPE, false>::operator*()
12646{
12647 BSLS_ASSERT(has_value());
12648
12649 return d_value.value();
12650}
12651# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12652
12653template <class t_TYPE>
12654inline
12655t_TYPE *Optional_Base<t_TYPE, false>::operator->()
12656{
12657 BSLS_ASSERT(has_value());
12658
12659 return BSLS_UTIL_ADDRESSOF(d_value.value());
12660}
12661
12662// ACCESSORS
12663
12664template <class t_TYPE>
12665inline
12666bool Optional_Base<t_TYPE, false>::has_value() const BSLS_KEYWORD_NOEXCEPT
12667{
12668 return d_value.hasValue();
12669}
12670
12671# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12672template <class t_TYPE>
12673inline
12674const t_TYPE&
12675Optional_Base<t_TYPE, false>::value() const&
12676{
12677 if (!has_value())
12678 BSLS_THROW(bsl::bad_optional_access());
12679
12680 return d_value.value();
12681}
12682
12683template <class t_TYPE>
12684inline
12685const t_TYPE&&
12686Optional_Base<t_TYPE, false>::value() const&&
12687{
12688 if (!has_value())
12689 BSLS_THROW(bsl::bad_optional_access());
12690
12691 return std::move(d_value.value());
12692}
12693
12694# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12695template <class t_TYPE>
12696inline
12697const t_TYPE&
12698Optional_Base<t_TYPE, false>::value() const
12699{
12700 if (!has_value())
12701 BSLS_THROW(bsl::bad_optional_access());
12702
12703 return d_value.value();
12704}
12705
12706# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
12707
12708# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12709
12710template <class t_TYPE>
12711template <class t_ANY_TYPE>
12712inline
12713t_TYPE
12714Optional_Base<t_TYPE, false>::value_or(
12715 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
12716const &
12717{
12718 if (has_value()) {
12719 return t_TYPE(d_value.value()); // RETURN
12720 }
12721 else {
12722 return t_TYPE(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE,
12723 value)); // RETURN
12724 }
12725}
12726
12727# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12728template <class t_TYPE>
12729template <class t_ANY_TYPE>
12730inline
12731t_TYPE
12732Optional_Base<t_TYPE, false>::value_or(
12733 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
12734const
12735{
12736 if (has_value()) {
12737 return t_TYPE(d_value.value()); // RETURN
12738 }
12739 else {
12740 return t_TYPE(BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE,
12741 value)); // RETURN
12742 }
12743}
12744
12745# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
12746
12747template <class t_TYPE>
12748inline
12749const t_TYPE *Optional_Base<t_TYPE, false>::operator->() const
12750{
12751 BSLS_ASSERT(has_value());
12752
12753 return BSLS_UTIL_ADDRESSOF(d_value.value());
12754}
12755
12756# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12757template <class t_TYPE>
12758inline
12759const t_TYPE& Optional_Base<t_TYPE, false>::operator*() const&
12760{
12761 BSLS_ASSERT(has_value());
12762
12763 return d_value.value();
12764}
12765
12766template <class t_TYPE>
12767inline
12768const t_TYPE&& Optional_Base<t_TYPE, false>::operator*() const&&
12769{
12770 BSLS_ASSERT(has_value());
12771
12772 return std::move(d_value.value());
12773}
12774
12775# else // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
12776template <class t_TYPE>
12777inline
12778const t_TYPE& Optional_Base<t_TYPE, false>::operator*() const
12779{
12780 BSLS_ASSERT(has_value());
12781
12782 return d_value.value();
12783}
12784# endif // BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS else
12785
12786#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
12787template <class t_TYPE>
12788Optional_Base<t_TYPE, false>::operator bool() const BSLS_KEYWORD_NOEXCEPT
12789{
12790 return has_value();
12791}
12792#endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
12793# endif // else BSLSTL_OPTIONAL_USES_STD_ALIASES
12794
12795} // close package namespace
12796
12797
12798// ============================================================================
12799// Section: 'optional' Method Definitions
12800// ============================================================================
12801
12802 // ==============
12803 // class optional
12804 // ==============
12805
12806namespace bsl {
12807
12808#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
12809// PRIVATE CREATORS
12810template <class t_TYPE>
12811template <class t_INVOCABLE, class t_ARG>
12812inline
12814 BloombergLP::bslstl::Optional_InvokeConstructorTag tag,
12815 t_INVOCABLE&& invocable,
12816 t_ARG&& arg)
12817: BaseType(tag, std::forward<t_INVOCABLE>(invocable), std::forward<t_ARG>(arg))
12818{
12819}
12820#endif
12821
12822// CREATORS
12823template <class t_TYPE>
12824BSLSTL_OPTIONAL_CONSTEXPR17 optional<t_TYPE>::optional() BSLS_KEYWORD_NOEXCEPT
12825: BaseType()
12826{
12827}
12828
12829template <class t_TYPE>
12831optional<t_TYPE>::optional(bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
12832: BaseType()
12833{
12834}
12835
12836#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
12837template <class t_TYPE>
12838template <class t_DERIVED>
12839optional<t_TYPE>::optional(
12840 BloombergLP::bslmf::MovableRef<t_DERIVED> original,
12844: BaseType(MoveUtil::move(static_cast<BaseType&>(original)))
12845{
12846}
12847#endif
12848
12849template <class t_TYPE>
12850template <class t_ANY_TYPE>
12851BSLSTL_OPTIONAL_CONSTEXPR17 optional<t_TYPE>::optional(
12852 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
12855: BaseType(BloombergLP::bslstl::Optional_ConstructFromForwardRef(),
12856 BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value))
12857{
12858}
12859
12860template <class t_TYPE>
12861template <class t_ANY_TYPE>
12862BSLSTL_OPTIONAL_CONSTEXPR17 optional<t_TYPE>::optional(
12863 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
12866: BaseType(BloombergLP::bslstl::Optional_ConstructFromForwardRef(),
12867 BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value))
12868{
12869}
12870
12871template <class t_TYPE>
12872template <class t_ANY_TYPE>
12873BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12874 const optional<t_ANY_TYPE>& original,
12876 const t_ANY_TYPE&),
12878 const t_ANY_TYPE&))
12879: BaseType(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional(),
12880 original)
12881{
12882}
12883
12884template <class t_TYPE>
12885template <class t_ANY_TYPE>
12886BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12887 const optional<t_ANY_TYPE>& original,
12889 const t_ANY_TYPE&),
12890 BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE&))
12891: BaseType(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional(),
12892 original)
12893{
12894}
12895
12896template <class t_TYPE>
12897template <class t_ANY_TYPE>
12898BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12899 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
12902: BaseType(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional(),
12903 MoveUtil::move(
12904 static_cast<BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>&>(
12905 original)))
12906{
12907}
12908
12909template <class t_TYPE>
12910template <class t_ANY_TYPE>
12911BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12912 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
12915: BaseType(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional(),
12916 MoveUtil::move(
12917 static_cast<BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>&>(
12918 original)))
12919{
12920}
12921
12922#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
12923template <class t_TYPE>
12924template <class t_ANY_TYPE>
12925BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12926 const std::optional<t_ANY_TYPE>& original,
12928 const t_ANY_TYPE&),
12930: BaseType(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional(),
12931 original)
12932{
12933}
12934
12935template <class t_TYPE>
12936template <class t_ANY_TYPE>
12937BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12938 const std::optional<t_ANY_TYPE>& original,
12940 const t_ANY_TYPE&),
12942: BaseType(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional(),
12943 original)
12944{
12945}
12946
12947template <class t_TYPE>
12948template <class t_ANY_TYPE>
12949BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12950 std::optional<t_ANY_TYPE>&& original,
12953: BaseType(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional(),
12954 std::move(original))
12955{
12956}
12957
12958template <class t_TYPE>
12959template <class t_ANY_TYPE>
12960BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>::optional(
12961 std::optional<t_ANY_TYPE>&& original,
12964: BaseType(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional(),
12965 std::move(original))
12966{
12967}
12968# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
12969
12970#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
12971// {{{ BEGIN GENERATED CODE
12972// Command line: sim_cpp11_features.pl bslstl_optional.h
12973#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
12974#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
12975#endif
12976#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_S
12977#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_S BSLSTL_OPTIONAL_VARIADIC_LIMIT
12978#endif
12979#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 0
12980template <class t_TYPE>
12982optional<t_TYPE>::optional(bsl::in_place_t)
12983: BaseType(bsl::in_place)
12984{
12985}
12986#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 0
12987
12988#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 1
12989template <class t_TYPE>
12990template <class t_ARGS_01>
12992optional<t_TYPE>::optional(bsl::in_place_t,
12993 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
12994: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01))
12995{
12996}
12997#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 1
12998
12999#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 2
13000template <class t_TYPE>
13001template <class t_ARGS_01,
13002 class t_ARGS_02>
13004optional<t_TYPE>::optional(bsl::in_place_t,
13005 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13006 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
13007: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13008 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02))
13009{
13010}
13011#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 2
13012
13013#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 3
13014template <class t_TYPE>
13015template <class t_ARGS_01,
13016 class t_ARGS_02,
13017 class t_ARGS_03>
13019optional<t_TYPE>::optional(bsl::in_place_t,
13020 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13021 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13022 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
13023: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13024 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13025 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03))
13026{
13027}
13028#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 3
13029
13030#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 4
13031template <class t_TYPE>
13032template <class t_ARGS_01,
13033 class t_ARGS_02,
13034 class t_ARGS_03,
13035 class t_ARGS_04>
13037optional<t_TYPE>::optional(bsl::in_place_t,
13038 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13039 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13040 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13041 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
13042: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13043 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13044 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13045 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04))
13046{
13047}
13048#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 4
13049
13050#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 5
13051template <class t_TYPE>
13052template <class t_ARGS_01,
13053 class t_ARGS_02,
13054 class t_ARGS_03,
13055 class t_ARGS_04,
13056 class t_ARGS_05>
13058optional<t_TYPE>::optional(bsl::in_place_t,
13059 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13060 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13061 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13062 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13063 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
13064: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13065 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13066 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13067 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13068 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05))
13069{
13070}
13071#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 5
13072
13073#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 6
13074template <class t_TYPE>
13075template <class t_ARGS_01,
13076 class t_ARGS_02,
13077 class t_ARGS_03,
13078 class t_ARGS_04,
13079 class t_ARGS_05,
13080 class t_ARGS_06>
13082optional<t_TYPE>::optional(bsl::in_place_t,
13083 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13084 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13085 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13086 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13087 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13088 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
13089: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13090 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13091 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13092 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13093 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13094 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06))
13095{
13096}
13097#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 6
13098
13099#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 7
13100template <class t_TYPE>
13101template <class t_ARGS_01,
13102 class t_ARGS_02,
13103 class t_ARGS_03,
13104 class t_ARGS_04,
13105 class t_ARGS_05,
13106 class t_ARGS_06,
13107 class t_ARGS_07>
13109optional<t_TYPE>::optional(bsl::in_place_t,
13110 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13112 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13113 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13114 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13115 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13116 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
13117: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13118 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13119 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13120 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13121 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13122 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13123 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07))
13124{
13125}
13126#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 7
13127
13128#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 8
13129template <class t_TYPE>
13130template <class t_ARGS_01,
13131 class t_ARGS_02,
13132 class t_ARGS_03,
13133 class t_ARGS_04,
13134 class t_ARGS_05,
13135 class t_ARGS_06,
13136 class t_ARGS_07,
13137 class t_ARGS_08>
13139optional<t_TYPE>::optional(bsl::in_place_t,
13140 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13141 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13142 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13143 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13144 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13145 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13146 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13147 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
13148: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13149 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13150 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13151 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13152 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13153 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13154 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13155 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08))
13156{
13157}
13158#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 8
13159
13160#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 9
13161template <class t_TYPE>
13162template <class t_ARGS_01,
13163 class t_ARGS_02,
13164 class t_ARGS_03,
13165 class t_ARGS_04,
13166 class t_ARGS_05,
13167 class t_ARGS_06,
13168 class t_ARGS_07,
13169 class t_ARGS_08,
13170 class t_ARGS_09>
13172optional<t_TYPE>::optional(bsl::in_place_t,
13173 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13174 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13175 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13176 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13177 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13178 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13179 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13180 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
13181 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
13182: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13183 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13184 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13185 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13186 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13187 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13188 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13189 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
13190 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09))
13191{
13192}
13193#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 9
13194
13195#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 10
13196template <class t_TYPE>
13197template <class t_ARGS_01,
13198 class t_ARGS_02,
13199 class t_ARGS_03,
13200 class t_ARGS_04,
13201 class t_ARGS_05,
13202 class t_ARGS_06,
13203 class t_ARGS_07,
13204 class t_ARGS_08,
13205 class t_ARGS_09,
13206 class t_ARGS_10>
13208optional<t_TYPE>::optional(bsl::in_place_t,
13209 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13210 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13211 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13212 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13213 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13214 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13215 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13216 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
13217 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
13218 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
13219: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13220 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13221 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13222 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13223 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13224 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13225 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13226 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
13227 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
13228 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10))
13229{
13230}
13231#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 10
13232
13233#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
13234#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 0
13235template <class t_TYPE>
13236template <class t_INIT_LIST_TYPE>
13238optional<t_TYPE>::optional(bsl::in_place_t,
13239 std::initializer_list<t_INIT_LIST_TYPE> il)
13240: BaseType(bsl::in_place, il)
13241{
13242}
13243#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 0
13244
13245#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 1
13246template <class t_TYPE>
13247template <class t_INIT_LIST_TYPE, class t_ARGS_01>
13249optional<t_TYPE>::optional(bsl::in_place_t,
13250 std::initializer_list<t_INIT_LIST_TYPE> il,
13251 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
13252: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01))
13253{
13254}
13255#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 1
13256
13257#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 2
13258template <class t_TYPE>
13259template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13260 class t_ARGS_02>
13262optional<t_TYPE>::optional(bsl::in_place_t,
13263 std::initializer_list<t_INIT_LIST_TYPE> il,
13264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13265 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
13266: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13267 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02))
13268{
13269}
13270#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 2
13271
13272#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 3
13273template <class t_TYPE>
13274template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13275 class t_ARGS_02,
13276 class t_ARGS_03>
13278optional<t_TYPE>::optional(bsl::in_place_t,
13279 std::initializer_list<t_INIT_LIST_TYPE> il,
13280 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13282 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
13283: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13284 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13285 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03))
13286{
13287}
13288#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 3
13289
13290#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 4
13291template <class t_TYPE>
13292template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13293 class t_ARGS_02,
13294 class t_ARGS_03,
13295 class t_ARGS_04>
13297optional<t_TYPE>::optional(bsl::in_place_t,
13298 std::initializer_list<t_INIT_LIST_TYPE> il,
13299 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13300 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13301 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13302 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
13303: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13304 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13305 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13306 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04))
13307{
13308}
13309#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 4
13310
13311#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 5
13312template <class t_TYPE>
13313template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13314 class t_ARGS_02,
13315 class t_ARGS_03,
13316 class t_ARGS_04,
13317 class t_ARGS_05>
13319optional<t_TYPE>::optional(bsl::in_place_t,
13320 std::initializer_list<t_INIT_LIST_TYPE> il,
13321 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13322 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13323 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13324 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13325 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
13326: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13327 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13328 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13329 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13330 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05))
13331{
13332}
13333#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 5
13334
13335#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 6
13336template <class t_TYPE>
13337template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13338 class t_ARGS_02,
13339 class t_ARGS_03,
13340 class t_ARGS_04,
13341 class t_ARGS_05,
13342 class t_ARGS_06>
13344optional<t_TYPE>::optional(bsl::in_place_t,
13345 std::initializer_list<t_INIT_LIST_TYPE> il,
13346 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
13352: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13353 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13354 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13355 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13356 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13357 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06))
13358{
13359}
13360#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 6
13361
13362#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 7
13363template <class t_TYPE>
13364template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13365 class t_ARGS_02,
13366 class t_ARGS_03,
13367 class t_ARGS_04,
13368 class t_ARGS_05,
13369 class t_ARGS_06,
13370 class t_ARGS_07>
13372optional<t_TYPE>::optional(bsl::in_place_t,
13373 std::initializer_list<t_INIT_LIST_TYPE> il,
13374 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13375 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13376 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13377 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13378 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13379 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13380 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
13381: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13382 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13383 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13384 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13385 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13386 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13387 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07))
13388{
13389}
13390#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 7
13391
13392#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 8
13393template <class t_TYPE>
13394template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13395 class t_ARGS_02,
13396 class t_ARGS_03,
13397 class t_ARGS_04,
13398 class t_ARGS_05,
13399 class t_ARGS_06,
13400 class t_ARGS_07,
13401 class t_ARGS_08>
13403optional<t_TYPE>::optional(bsl::in_place_t,
13404 std::initializer_list<t_INIT_LIST_TYPE> il,
13405 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13406 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13407 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13408 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13409 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13410 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13411 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13412 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
13413: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13414 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13415 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13416 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13417 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13418 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13419 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13420 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08))
13421{
13422}
13423#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 8
13424
13425#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 9
13426template <class t_TYPE>
13427template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13428 class t_ARGS_02,
13429 class t_ARGS_03,
13430 class t_ARGS_04,
13431 class t_ARGS_05,
13432 class t_ARGS_06,
13433 class t_ARGS_07,
13434 class t_ARGS_08,
13435 class t_ARGS_09>
13437optional<t_TYPE>::optional(bsl::in_place_t,
13438 std::initializer_list<t_INIT_LIST_TYPE> il,
13439 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13440 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13441 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13442 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13443 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13444 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13445 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13446 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
13447 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
13448: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13449 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13450 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13451 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13452 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13453 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13454 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13455 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
13456 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09))
13457{
13458}
13459#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 9
13460
13461#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 10
13462template <class t_TYPE>
13463template <class t_INIT_LIST_TYPE, class t_ARGS_01,
13464 class t_ARGS_02,
13465 class t_ARGS_03,
13466 class t_ARGS_04,
13467 class t_ARGS_05,
13468 class t_ARGS_06,
13469 class t_ARGS_07,
13470 class t_ARGS_08,
13471 class t_ARGS_09,
13472 class t_ARGS_10>
13474optional<t_TYPE>::optional(bsl::in_place_t,
13475 std::initializer_list<t_INIT_LIST_TYPE> il,
13476 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13477 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13478 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13479 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13480 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13481 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13482 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13483 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
13484 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
13485 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
13486: BaseType(bsl::in_place, il,BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13487 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13488 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13489 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13490 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13491 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13492 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13493 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
13494 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
13495 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10))
13496{
13497}
13498#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_S >= 10
13499
13500#endif
13501#else
13502// The generated code below is a workaround for the absence of perfect
13503// forwarding in some compilers.
13504template <class t_TYPE>
13505template <class... t_ARGS>
13507optional<t_TYPE>::optional(bsl::in_place_t,
13508 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
13509: BaseType(bsl::in_place, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...)
13510{
13511}
13512#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
13513template <class t_TYPE>
13514template <class t_INIT_LIST_TYPE, class... t_ARGS>
13516optional<t_TYPE>::optional(bsl::in_place_t,
13517 std::initializer_list<t_INIT_LIST_TYPE> il,
13518 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
13519: BaseType(bsl::in_place, il, BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...)
13520{
13521}
13522#endif
13523// }}} END GENERATED CODE
13524#endif
13525
13526template <class t_TYPE>
13527optional<t_TYPE>::optional(bsl::allocator_arg_t, AllocType allocator)
13528: BaseType(bsl::allocator_arg, allocator)
13529{
13530}
13531
13532template <class t_TYPE>
13533optional<t_TYPE>::optional(bsl::allocator_arg_t,
13534 AllocType allocator,
13536: BaseType(bsl::allocator_arg, allocator)
13537{
13538}
13539
13540template <class t_TYPE>
13541optional<t_TYPE>::optional(bsl::allocator_arg_t,
13542 AllocType allocator,
13543 const optional& original)
13544: BaseType(bsl::allocator_arg, allocator, original)
13545{
13546}
13547
13548template <class t_TYPE>
13549template <class t_DERIVED>
13550optional<t_TYPE>::optional(bsl::allocator_arg_t,
13551 AllocType allocator,
13552 BSLMF_MOVABLEREF_DEDUCE(t_DERIVED) original,
13555: BaseType(bsl::allocator_arg_t(),
13556 allocator,
13557 MoveUtil::move(static_cast<BaseType&>(original)))
13558{
13559 // Implementation Note: The @ref remove_reference in the signature is needed
13560 // to work around a bug in GCC 10. (It has not been determined whether
13561 // other versions are affected.)
13562}
13563
13564template <class t_TYPE>
13565template <class t_ANY_TYPE>
13566optional<t_TYPE>::optional(
13568 AllocType allocator,
13569 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
13572: BaseType(bsl::allocator_arg_t(),
13573 allocator,
13574 BloombergLP::bslstl::Optional_ConstructFromForwardRef(),
13575 BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value))
13576{
13577}
13578
13579template <class t_TYPE>
13580template <class t_ANY_TYPE>
13581optional<t_TYPE>::optional(
13583 AllocType allocator,
13584 BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value,
13587: BaseType(bsl::allocator_arg_t(),
13588 allocator,
13589 BloombergLP::bslstl::Optional_ConstructFromForwardRef(),
13590 BSLS_COMPILERFEATURES_FORWARD(t_ANY_TYPE, value))
13591{
13592}
13593
13594template <class t_TYPE>
13595template <class t_ANY_TYPE>
13596optional<t_TYPE>::optional(
13598 AllocType allocator,
13599 const optional<t_ANY_TYPE>& original,
13601 const t_ANY_TYPE&),
13603 const t_ANY_TYPE&))
13604: BaseType(bsl::allocator_arg_t(),
13605 allocator,
13606 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional(),
13607 original)
13608{
13609}
13610
13611template <class t_TYPE>
13612template <class t_ANY_TYPE>
13613optional<t_TYPE>::optional(
13615 AllocType allocator,
13616 const optional<t_ANY_TYPE>& original,
13618 const t_ANY_TYPE&),
13619 BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE&))
13620: BaseType(bsl::allocator_arg_t(),
13621 allocator,
13622 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional(),
13623 original)
13624{
13625}
13626
13627template <class t_TYPE>
13628template <class t_ANY_TYPE>
13629optional<t_TYPE>::optional(
13631 AllocType allocator,
13632 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
13635: BaseType(bsl::allocator_arg_t(),
13636 allocator,
13637 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional(),
13638 MoveUtil::move(
13639 static_cast<BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>&>(
13640 original)))
13641{
13642}
13643
13644template <class t_TYPE>
13645template <class t_ANY_TYPE>
13646optional<t_TYPE>::optional(
13648 AllocType allocator,
13649 BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) original,
13652: BaseType(bsl::allocator_arg_t(),
13653 allocator,
13654 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional(),
13655 MoveUtil::move(
13656 static_cast<BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>&>(
13657 original)))
13658{
13659}
13660
13661#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
13662template <class t_TYPE>
13663template <class t_ANY_TYPE>
13664optional<t_TYPE>::optional(
13666 AllocType allocator,
13667 const std::optional<t_ANY_TYPE>& original,
13669 const t_ANY_TYPE&),
13671 const t_ANY_TYPE&))
13672: BaseType(bsl::allocator_arg_t(),
13673 allocator,
13674 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional(),
13675 original)
13676{
13677}
13678
13679template <class t_TYPE>
13680template <class t_ANY_TYPE>
13681optional<t_TYPE>::optional(
13683 AllocType allocator,
13684 const std::optional<t_ANY_TYPE>& original,
13686 const t_ANY_TYPE&),
13687 BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE))
13688: BaseType(bsl::allocator_arg_t(),
13689 allocator,
13690 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional(),
13691 original)
13692{
13693}
13694
13695template <class t_TYPE>
13696template <class t_ANY_TYPE>
13697optional<t_TYPE>::optional(
13699 AllocType allocator,
13700 std::optional<t_ANY_TYPE>&& original,
13703: BaseType(bsl::allocator_arg_t(),
13704 allocator,
13705 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional(),
13706 std::move(original))
13707{
13708}
13709
13710template <class t_TYPE>
13711template <class t_ANY_TYPE>
13712optional<t_TYPE>::optional(
13714 AllocType allocator,
13715 std::optional<t_ANY_TYPE>&& original,
13718: BaseType(bsl::allocator_arg_t(),
13719 allocator,
13720 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional(),
13721 std::move(original))
13722{
13723}
13724# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
13725
13726#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
13727// {{{ BEGIN GENERATED CODE
13728// Command line: sim_cpp11_features.pl bslstl_optional.h
13729#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
13730#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
13731#endif
13732#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_T
13733#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_T BSLSTL_OPTIONAL_VARIADIC_LIMIT
13734#endif
13735#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 0
13736template <class t_TYPE>
13737optional<t_TYPE>::optional(
13739 AllocType allocator,
13741: BaseType(bsl::allocator_arg,
13742 allocator,
13743 bsl::in_place)
13744{
13745}
13746#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 0
13747
13748#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 1
13749template <class t_TYPE>
13750template <class t_ARGS_01>
13751optional<t_TYPE>::optional(
13753 AllocType allocator,
13755 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
13756: BaseType(bsl::allocator_arg,
13757 allocator,
13758 bsl::in_place,
13759 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01))
13760{
13761}
13762#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 1
13763
13764#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 2
13765template <class t_TYPE>
13766template <class t_ARGS_01,
13767 class t_ARGS_02>
13768optional<t_TYPE>::optional(
13770 AllocType allocator,
13772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13773 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
13774: BaseType(bsl::allocator_arg,
13775 allocator,
13776 bsl::in_place,
13777 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13778 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02))
13779{
13780}
13781#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 2
13782
13783#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 3
13784template <class t_TYPE>
13785template <class t_ARGS_01,
13786 class t_ARGS_02,
13787 class t_ARGS_03>
13788optional<t_TYPE>::optional(
13790 AllocType allocator,
13792 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13793 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13794 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
13795: BaseType(bsl::allocator_arg,
13796 allocator,
13797 bsl::in_place,
13798 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13799 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13800 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03))
13801{
13802}
13803#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 3
13804
13805#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 4
13806template <class t_TYPE>
13807template <class t_ARGS_01,
13808 class t_ARGS_02,
13809 class t_ARGS_03,
13810 class t_ARGS_04>
13811optional<t_TYPE>::optional(
13813 AllocType allocator,
13815 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13816 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13817 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
13819: BaseType(bsl::allocator_arg,
13820 allocator,
13821 bsl::in_place,
13822 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13823 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13824 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13825 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04))
13826{
13827}
13828#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 4
13829
13830#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 5
13831template <class t_TYPE>
13832template <class t_ARGS_01,
13833 class t_ARGS_02,
13834 class t_ARGS_03,
13835 class t_ARGS_04,
13836 class t_ARGS_05>
13837optional<t_TYPE>::optional(
13839 AllocType allocator,
13841 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13842 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13843 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13844 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13845 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
13846: BaseType(bsl::allocator_arg,
13847 allocator,
13848 bsl::in_place,
13849 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13850 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13851 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13852 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13853 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05))
13854{
13855}
13856#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 5
13857
13858#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 6
13859template <class t_TYPE>
13860template <class t_ARGS_01,
13861 class t_ARGS_02,
13862 class t_ARGS_03,
13863 class t_ARGS_04,
13864 class t_ARGS_05,
13865 class t_ARGS_06>
13866optional<t_TYPE>::optional(
13868 AllocType allocator,
13870 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13871 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13872 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13873 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13874 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13875 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
13876: BaseType(bsl::allocator_arg,
13877 allocator,
13878 bsl::in_place,
13879 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13880 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13881 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13882 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13883 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13884 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06))
13885{
13886}
13887#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 6
13888
13889#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 7
13890template <class t_TYPE>
13891template <class t_ARGS_01,
13892 class t_ARGS_02,
13893 class t_ARGS_03,
13894 class t_ARGS_04,
13895 class t_ARGS_05,
13896 class t_ARGS_06,
13897 class t_ARGS_07>
13898optional<t_TYPE>::optional(
13900 AllocType allocator,
13902 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13903 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13904 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13905 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13906 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13907 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13908 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
13909: BaseType(bsl::allocator_arg,
13910 allocator,
13911 bsl::in_place,
13912 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13913 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13914 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13915 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13916 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13917 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13918 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07))
13919{
13920}
13921#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 7
13922
13923#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 8
13924template <class t_TYPE>
13925template <class t_ARGS_01,
13926 class t_ARGS_02,
13927 class t_ARGS_03,
13928 class t_ARGS_04,
13929 class t_ARGS_05,
13930 class t_ARGS_06,
13931 class t_ARGS_07,
13932 class t_ARGS_08>
13933optional<t_TYPE>::optional(
13935 AllocType allocator,
13937 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13938 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13939 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13940 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13941 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13942 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13943 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
13945: BaseType(bsl::allocator_arg,
13946 allocator,
13947 bsl::in_place,
13948 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13949 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13950 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13951 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13952 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13953 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13954 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13955 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08))
13956{
13957}
13958#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 8
13959
13960#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 9
13961template <class t_TYPE>
13962template <class t_ARGS_01,
13963 class t_ARGS_02,
13964 class t_ARGS_03,
13965 class t_ARGS_04,
13966 class t_ARGS_05,
13967 class t_ARGS_06,
13968 class t_ARGS_07,
13969 class t_ARGS_08,
13970 class t_ARGS_09>
13971optional<t_TYPE>::optional(
13973 AllocType allocator,
13975 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
13976 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
13977 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
13978 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
13979 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
13980 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
13981 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
13982 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
13983 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
13984: BaseType(bsl::allocator_arg,
13985 allocator,
13986 bsl::in_place,
13987 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
13988 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
13989 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
13990 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
13991 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
13992 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
13993 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
13994 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
13995 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09))
13996{
13997}
13998#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 9
13999
14000#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 10
14001template <class t_TYPE>
14002template <class t_ARGS_01,
14003 class t_ARGS_02,
14004 class t_ARGS_03,
14005 class t_ARGS_04,
14006 class t_ARGS_05,
14007 class t_ARGS_06,
14008 class t_ARGS_07,
14009 class t_ARGS_08,
14010 class t_ARGS_09,
14011 class t_ARGS_10>
14012optional<t_TYPE>::optional(
14014 AllocType allocator,
14016 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14017 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14018 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14019 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14020 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14021 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
14022 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
14023 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
14024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
14025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
14026: BaseType(bsl::allocator_arg,
14027 allocator,
14028 bsl::in_place,
14029 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14030 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14031 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14032 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14033 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14034 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
14035 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
14036 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
14037 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
14038 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10))
14039{
14040}
14041#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 10
14042
14043#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
14044#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 0
14045template <class t_TYPE>
14046template <class t_INIT_LIST_TYPE>
14047optional<t_TYPE>::optional(
14049 AllocType allocator,
14051 std::initializer_list<t_INIT_LIST_TYPE> il)
14052: BaseType(bsl::allocator_arg,
14053 allocator,
14054 bsl::in_place,
14055 il)
14056{
14057}
14058#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 0
14059
14060#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 1
14061template <class t_TYPE>
14062template <class t_INIT_LIST_TYPE, class t_ARGS_01>
14063optional<t_TYPE>::optional(
14065 AllocType allocator,
14067 std::initializer_list<t_INIT_LIST_TYPE> il,
14068 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
14069: BaseType(bsl::allocator_arg,
14070 allocator,
14071 bsl::in_place,
14072 il,
14073 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01))
14074{
14075}
14076#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 1
14077
14078#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 2
14079template <class t_TYPE>
14080template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14081 class t_ARGS_02>
14082optional<t_TYPE>::optional(
14084 AllocType allocator,
14086 std::initializer_list<t_INIT_LIST_TYPE> il,
14087 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14088 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
14089: BaseType(bsl::allocator_arg,
14090 allocator,
14091 bsl::in_place,
14092 il,
14093 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14094 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02))
14095{
14096}
14097#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 2
14098
14099#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 3
14100template <class t_TYPE>
14101template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14102 class t_ARGS_02,
14103 class t_ARGS_03>
14104optional<t_TYPE>::optional(
14106 AllocType allocator,
14108 std::initializer_list<t_INIT_LIST_TYPE> il,
14109 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14110 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14111 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
14112: BaseType(bsl::allocator_arg,
14113 allocator,
14114 bsl::in_place,
14115 il,
14116 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14117 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14118 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03))
14119{
14120}
14121#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 3
14122
14123#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 4
14124template <class t_TYPE>
14125template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14126 class t_ARGS_02,
14127 class t_ARGS_03,
14128 class t_ARGS_04>
14129optional<t_TYPE>::optional(
14131 AllocType allocator,
14133 std::initializer_list<t_INIT_LIST_TYPE> il,
14134 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14135 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14136 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14137 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
14138: BaseType(bsl::allocator_arg,
14139 allocator,
14140 bsl::in_place,
14141 il,
14142 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14143 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14144 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14145 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04))
14146{
14147}
14148#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 4
14149
14150#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 5
14151template <class t_TYPE>
14152template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14153 class t_ARGS_02,
14154 class t_ARGS_03,
14155 class t_ARGS_04,
14156 class t_ARGS_05>
14157optional<t_TYPE>::optional(
14159 AllocType allocator,
14161 std::initializer_list<t_INIT_LIST_TYPE> il,
14162 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14163 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14164 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14165 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14166 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
14167: BaseType(bsl::allocator_arg,
14168 allocator,
14169 bsl::in_place,
14170 il,
14171 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14172 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14173 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14174 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14175 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05))
14176{
14177}
14178#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 5
14179
14180#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 6
14181template <class t_TYPE>
14182template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14183 class t_ARGS_02,
14184 class t_ARGS_03,
14185 class t_ARGS_04,
14186 class t_ARGS_05,
14187 class t_ARGS_06>
14188optional<t_TYPE>::optional(
14190 AllocType allocator,
14192 std::initializer_list<t_INIT_LIST_TYPE> il,
14193 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14194 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14195 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14196 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14197 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14198 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
14199: BaseType(bsl::allocator_arg,
14200 allocator,
14201 bsl::in_place,
14202 il,
14203 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14204 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14205 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14206 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14207 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14208 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06))
14209{
14210}
14211#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 6
14212
14213#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 7
14214template <class t_TYPE>
14215template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14216 class t_ARGS_02,
14217 class t_ARGS_03,
14218 class t_ARGS_04,
14219 class t_ARGS_05,
14220 class t_ARGS_06,
14221 class t_ARGS_07>
14222optional<t_TYPE>::optional(
14224 AllocType allocator,
14226 std::initializer_list<t_INIT_LIST_TYPE> il,
14227 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14228 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14229 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14230 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14231 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14232 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
14233 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
14234: BaseType(bsl::allocator_arg,
14235 allocator,
14236 bsl::in_place,
14237 il,
14238 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14239 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14240 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14241 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14242 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14243 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
14244 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07))
14245{
14246}
14247#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 7
14248
14249#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 8
14250template <class t_TYPE>
14251template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14252 class t_ARGS_02,
14253 class t_ARGS_03,
14254 class t_ARGS_04,
14255 class t_ARGS_05,
14256 class t_ARGS_06,
14257 class t_ARGS_07,
14258 class t_ARGS_08>
14259optional<t_TYPE>::optional(
14261 AllocType allocator,
14263 std::initializer_list<t_INIT_LIST_TYPE> il,
14264 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14265 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14266 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14267 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14268 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14269 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
14270 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
14271 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
14272: BaseType(bsl::allocator_arg,
14273 allocator,
14274 bsl::in_place,
14275 il,
14276 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14277 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14278 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14279 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14280 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14281 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
14282 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
14283 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08))
14284{
14285}
14286#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 8
14287
14288#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 9
14289template <class t_TYPE>
14290template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14291 class t_ARGS_02,
14292 class t_ARGS_03,
14293 class t_ARGS_04,
14294 class t_ARGS_05,
14295 class t_ARGS_06,
14296 class t_ARGS_07,
14297 class t_ARGS_08,
14298 class t_ARGS_09>
14299optional<t_TYPE>::optional(
14301 AllocType allocator,
14303 std::initializer_list<t_INIT_LIST_TYPE> il,
14304 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14305 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14306 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14307 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14308 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14309 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
14310 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
14311 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
14312 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
14313: BaseType(bsl::allocator_arg,
14314 allocator,
14315 bsl::in_place,
14316 il,
14317 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14318 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14319 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14320 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14321 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14322 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
14323 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
14324 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
14325 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09))
14326{
14327}
14328#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 9
14329
14330#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 10
14331template <class t_TYPE>
14332template <class t_INIT_LIST_TYPE, class t_ARGS_01,
14333 class t_ARGS_02,
14334 class t_ARGS_03,
14335 class t_ARGS_04,
14336 class t_ARGS_05,
14337 class t_ARGS_06,
14338 class t_ARGS_07,
14339 class t_ARGS_08,
14340 class t_ARGS_09,
14341 class t_ARGS_10>
14342optional<t_TYPE>::optional(
14344 AllocType allocator,
14346 std::initializer_list<t_INIT_LIST_TYPE> il,
14347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
14348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
14349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
14350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
14351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
14352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
14353 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
14354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
14355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
14356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
14357: BaseType(bsl::allocator_arg,
14358 allocator,
14359 bsl::in_place,
14360 il,
14361 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
14362 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
14363 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
14364 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
14365 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
14366 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
14367 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
14368 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
14369 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
14370 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10))
14371{
14372}
14373#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_T >= 10
14374
14375#endif
14376#else
14377// The generated code below is a workaround for the absence of perfect
14378// forwarding in some compilers.
14379template <class t_TYPE>
14380template <class... t_ARGS>
14381optional<t_TYPE>::optional(
14383 AllocType allocator,
14385 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
14386: BaseType(bsl::allocator_arg,
14387 allocator,
14388 bsl::in_place,
14389 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...)
14390{
14391}
14392#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
14393template <class t_TYPE>
14394template <class t_INIT_LIST_TYPE, class... t_ARGS>
14395optional<t_TYPE>::optional(
14397 AllocType allocator,
14399 std::initializer_list<t_INIT_LIST_TYPE> il,
14400 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
14401: BaseType(bsl::allocator_arg,
14402 allocator,
14403 bsl::in_place,
14404 il,
14405 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...)
14406{
14407}
14408#endif
14409// }}} END GENERATED CODE
14410#endif
14411
14412// MANIPULATORS
14413template <class t_TYPE>
14414BSLSTL_OPTIONAL_CONSTEXPR20 optional<t_TYPE>&
14415optional<t_TYPE>::operator=(bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
14416{
14417 this->reset();
14418 return *this;
14419}
14420
14421#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
14422template <class t_TYPE>
14423template <class t_DERIVED>
14425optional<t_TYPE>::operator=(BloombergLP::bslmf::MovableRef<t_DERIVED> rhs)
14426{
14427 BaseType& lvalue = rhs;
14428 BaseType::operator=(MoveUtil::move(lvalue));
14429 return *this;
14430}
14431#endif
14432
14433template <class t_TYPE>
14434template <class t_ANY_TYPE>
14436BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE&)&
14437optional<t_TYPE>::operator=(const optional<t_ANY_TYPE>& rhs)
14438{
14439 if (rhs.has_value()) {
14440 this->assignOrEmplace(*rhs);
14441 } else {
14442 this->reset();
14443 }
14444 return *this;
14445}
14446
14447template <class t_TYPE>
14448template <class t_ANY_TYPE>
14451optional<t_TYPE>::operator=(BSLMF_MOVABLEREF_DEDUCE(optional<t_ANY_TYPE>) rhs)
14452{
14453 BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>& lvalue = rhs;
14454 if (lvalue.has_value()) {
14455 this->assignOrEmplace(MoveUtil::move(*lvalue));
14456 } else {
14457 this->reset();
14458 }
14459 return *this;
14460}
14461
14462#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
14463template <class t_TYPE>
14464template <class t_ANY_TYPE>
14467optional<t_TYPE>::operator=(t_ANY_TYPE&& rhs)
14468{
14469 this->assignOrEmplace(std::forward<t_ANY_TYPE>(rhs));
14470 return *this;
14471}
14472#else
14473template <class t_TYPE>
14474optional<t_TYPE>& optional<t_TYPE>::operator=(const t_TYPE& rhs)
14475{
14476 this->assignOrEmplace(rhs);
14477 return *this;
14478}
14479
14480template <class t_TYPE>
14481optional<t_TYPE>&
14482optional<t_TYPE>::operator=(BloombergLP::bslmf::MovableRef<t_TYPE> rhs)
14483{
14484 this->assignOrEmplace(MoveUtil::move(rhs));
14485 return *this;
14486}
14487
14488template <class t_TYPE>
14489template <class t_ANY_TYPE>
14491optional<t_TYPE>::operator=(const t_ANY_TYPE& rhs)
14492{
14493 this->assignOrEmplace(rhs);
14494 return *this;
14495}
14496
14497template <class t_TYPE>
14498template <class t_ANY_TYPE>
14500optional<t_TYPE>::operator=(BloombergLP::bslmf::MovableRef<t_ANY_TYPE> rhs)
14501{
14502 this->assignOrEmplace(MoveUtil::move(rhs));
14503 return *this;
14504}
14505#endif // RVALUES else
14506
14507#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
14508template <class t_TYPE>
14509template <class t_ANY_TYPE>
14511BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(t_TYPE, const t_ANY_TYPE&)&
14512optional<t_TYPE>::operator=(const std::optional<t_ANY_TYPE>& rhs)
14513{
14514 if (rhs.has_value()) {
14515 this->assignOrEmplace(*rhs);
14516 } else {
14517 this->reset();
14518 }
14519 return *this;
14520}
14521
14522template <class t_TYPE>
14523template <class t_ANY_TYPE>
14526optional<t_TYPE>::operator=(std::optional<t_ANY_TYPE>&& rhs)
14527{
14528 if (rhs.has_value()) {
14529 this->assignOrEmplace(std::move(*rhs));
14530 } else {
14531 this->reset();
14532 }
14533 return *this;
14534}
14535# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
14536
14537#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
14538template <class t_TYPE>
14539template <class t_FUNC>
14540constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) &
14541{
14542 using ResultType = std::remove_cv_t<std::invoke_result_t<t_FUNC, t_TYPE&>>;
14543 static_assert(!std::is_array_v<ResultType>,
14544 "The callable must return an array");
14545 static_assert(!std::is_same_v<ResultType, nullopt_t>,
14546 "The callable must not return nullopt_t");
14547 static_assert(!std::is_same_v<ResultType, in_place_t>,
14548 "The callable must not return in_place_t");
14549 static_assert(std::is_object_v<ResultType>,
14550 "The callable must return an object type");
14551
14552 if (this->has_value()) {
14553 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
14554 return optional<ResultType>{Optional_InvokeConstructorTag{},
14555 std::forward<t_FUNC>(func),
14556 **this};
14557 }
14558 return optional<ResultType>{};
14559}
14560
14561template <class t_TYPE>
14562template <class t_FUNC>
14563constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) const &
14564{
14565 using ResultType =
14566 std::remove_cv_t<std::invoke_result_t<t_FUNC, const t_TYPE&>>;
14567 static_assert(!std::is_array_v<ResultType>,
14568 "The callable must return an array");
14569 static_assert(!std::is_same_v<ResultType, nullopt_t>,
14570 "The callable must not return nullopt_t");
14571 static_assert(!std::is_same_v<ResultType, in_place_t>,
14572 "The callable must not return in_place_t");
14573 static_assert(std::is_object_v<ResultType>,
14574 "The callable must return an object type");
14575
14576 if (this->has_value()) {
14577 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
14578 return optional<ResultType>{Optional_InvokeConstructorTag{},
14579 std::forward<t_FUNC>(func),
14580 **this};
14581 }
14582 return optional<ResultType>{};
14583}
14584
14585template <class t_TYPE>
14586template <class t_FUNC>
14587constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) &&
14588{
14589 using ResultType =
14590 std::remove_cv_t<std::invoke_result_t<t_FUNC, t_TYPE&&>>;
14591 static_assert(!std::is_array_v<ResultType>,
14592 "The callable must return an array");
14593 static_assert(!std::is_same_v<ResultType, nullopt_t>,
14594 "The callable must not return nullopt_t");
14595 static_assert(!std::is_same_v<ResultType, in_place_t>,
14596 "The callable must not return in_place_t");
14597 static_assert(std::is_object_v<ResultType>,
14598 "The callable must return an object type");
14599
14600 if (this->has_value()) {
14601 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
14602 return optional<ResultType>{Optional_InvokeConstructorTag{},
14603 std::forward<t_FUNC>(func),
14604 std::move(**this)};
14605 }
14606 return optional<ResultType>{};
14607}
14608
14609template <class t_TYPE>
14610template <class t_FUNC>
14611constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) const &&
14612{
14613 using ResultType =
14614 std::remove_cv_t<std::invoke_result_t<t_FUNC, const t_TYPE&&>>;
14615 static_assert(!std::is_array_v<ResultType>,
14616 "The callable must return an array");
14617 static_assert(!std::is_same_v<ResultType, nullopt_t>,
14618 "The callable must not return nullopt_t");
14619 static_assert(!std::is_same_v<ResultType, in_place_t>,
14620 "The callable must not return in_place_t");
14621 static_assert(std::is_object_v<ResultType>,
14622 "The callable must return an object type");
14623
14624 if (this->has_value()) {
14625 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
14626 return optional<ResultType>{Optional_InvokeConstructorTag{},
14627 std::forward<t_FUNC>(func),
14628 std::move(**this)};
14629 }
14630 return optional<ResultType>{};
14631}
14632
14633template <class t_TYPE>
14634template <class t_FUNC>
14635constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) &
14636{
14637 using ResultType = std::remove_cv_t<std::remove_reference_t<
14638 std::invoke_result_t<t_FUNC, t_TYPE&>>>;
14639 using ::BloombergLP::bslstl::Optional_IsBslOptional;
14640 static_assert(Optional_IsBslOptional<ResultType>::value,
14641 "The callable must return bsl::optional");
14642
14643 if (this->has_value()) {
14644 return std::invoke(std::forward<t_FUNC>(func), **this);
14645 }
14646 return ResultType{};
14647}
14648
14649template <class t_TYPE>
14650template <class t_FUNC>
14651constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) const &
14652{
14653 using ResultType = std::remove_cv_t<std::remove_reference_t<
14654 std::invoke_result_t<t_FUNC, const t_TYPE&>>>;
14655 using ::BloombergLP::bslstl::Optional_IsBslOptional;
14656 static_assert(Optional_IsBslOptional<ResultType>::value,
14657 "The callable must return bsl::optional");
14658
14659 if (this->has_value()) {
14660 return std::invoke(std::forward<t_FUNC>(func), **this);
14661 }
14662 return ResultType{};
14663}
14664
14665template <class t_TYPE>
14666template <class t_FUNC>
14667constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) &&
14668{
14669 using ResultType = std::remove_cv_t<std::remove_reference_t<
14670 std::invoke_result_t<t_FUNC, t_TYPE&&>>>;
14671 using ::BloombergLP::bslstl::Optional_IsBslOptional;
14672 static_assert(Optional_IsBslOptional<ResultType>::value,
14673 "The callable must return bsl::optional");
14674
14675 if (this->has_value()) {
14676 return std::invoke(std::forward<t_FUNC>(func), std::move(**this));
14677 }
14678 return ResultType{};
14679}
14680
14681template <class t_TYPE>
14682template <class t_FUNC>
14683constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) const &&
14684{
14685 using ResultType = std::remove_cv_t<std::remove_reference_t<
14686 std::invoke_result_t<t_FUNC, const t_TYPE&&>>>;
14687 using ::BloombergLP::bslstl::Optional_IsBslOptional;
14688 static_assert(Optional_IsBslOptional<ResultType>::value,
14689 "The callable must return bsl::optional");
14690
14691 if (this->has_value()) {
14692 return std::invoke(std::forward<t_FUNC>(func), std::move(**this));
14693 }
14694 return ResultType{};
14695}
14696
14697template <class t_TYPE>
14698template <class t_FUNC>
14699constexpr
14700enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
14701 std::is_copy_constructible<t_TYPE>>,
14702 optional<t_TYPE>> optional<t_TYPE>::or_else(t_FUNC&& func) const &
14703{
14704 static_assert(std::is_same_v<remove_cvref_t<std::invoke_result_t<t_FUNC>>,
14705 optional<t_TYPE>>,
14706 "The callable must return bsl::optional<T>");
14707
14708 if (this->has_value()) {
14709 return *this;
14710 }
14711 return std::forward<t_FUNC>(func)();
14712}
14713
14714template <class t_TYPE>
14715template <class t_FUNC>
14716constexpr
14717enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
14718 std::is_move_constructible<t_TYPE>>,
14719 optional<t_TYPE>> optional<t_TYPE>::or_else(t_FUNC&& func) &&
14720{
14721 static_assert(std::is_same_v<remove_cvref_t<std::invoke_result_t<t_FUNC>>,
14722 optional<t_TYPE>>,
14723 "The callable must return bsl::optional<T>");
14724
14725 if (this->has_value()) {
14726 return std::move(*this);
14727 }
14728 return std::forward<t_FUNC>(func)();
14729}
14730#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
14731
14732// ============================================================================
14733// Section: Free Function Definitions
14734// ============================================================================
14735
14736template <class t_TYPE>
14737inline
14739 void>::type
14741{
14742 if (lhs.get_allocator() == rhs.get_allocator()) {
14743 lhs.swap(rhs);
14744
14745 return; // RETURN
14746 }
14747
14748 bsl::optional<t_TYPE> futureLhs(
14749 bsl::allocator_arg, lhs.get_allocator(), rhs);
14750 bsl::optional<t_TYPE> futureRhs(
14751 bsl::allocator_arg, rhs.get_allocator(), lhs);
14752
14753 futureLhs.swap(lhs);
14754 futureRhs.swap(rhs);
14755}
14756
14757template <class t_TYPE>
14760 void>::type
14762{
14763 lhs.swap(rhs);
14764}
14765
14766// HASH SPECIALIZATIONS
14767template <class t_HASHALG, class t_TYPE>
14768void hashAppend(t_HASHALG& hashAlg, const bsl::optional<t_TYPE>& input)
14769{
14770 using ::BloombergLP::bslh::hashAppend;
14771
14772 if (input.has_value()) {
14773 hashAppend(hashAlg, true);
14774 hashAppend(hashAlg, *input);
14775 }
14776 else {
14777 hashAppend(hashAlg, false);
14778 }
14779}
14780
14781// FREE OPERATORS
14782
14783template <class t_LHS_TYPE, class t_RHS_TYPE>
14786 const bsl::optional<t_RHS_TYPE>& rhs)
14787 BSLSTL_OPTIONAL_REQUIRES(requires {
14788 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14789 })
14790{
14791 if (lhs.has_value() && rhs.has_value()) {
14792 return *lhs == *rhs; // RETURN
14793 }
14794 return lhs.has_value() == rhs.has_value();
14795}
14796
14797template <class t_LHS_TYPE, class t_RHS_TYPE>
14800 const bsl::optional<t_RHS_TYPE>& rhs)
14801 BSLSTL_OPTIONAL_REQUIRES(requires {
14802 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14803 })
14804{
14805 if (lhs.has_value() && rhs.has_value()) {
14806 return *lhs != *rhs; // RETURN
14807 }
14808
14809 return lhs.has_value() != rhs.has_value();
14810}
14811
14812template <class t_LHS_TYPE, class t_RHS_TYPE>
14814bool operator<(const bsl::optional<t_LHS_TYPE>& lhs,
14815 const bsl::optional<t_RHS_TYPE>& rhs)
14816 BSLSTL_OPTIONAL_REQUIRES(requires {
14817 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14818 })
14819{
14820 if (!rhs.has_value()) {
14821 return false; // RETURN
14822 }
14823
14824 return !lhs.has_value() || *lhs < *rhs;
14825}
14826
14827template <class t_LHS_TYPE, class t_RHS_TYPE>
14829bool operator>(const bsl::optional<t_LHS_TYPE>& lhs,
14830 const bsl::optional<t_RHS_TYPE>& rhs)
14831 BSLSTL_OPTIONAL_REQUIRES(requires {
14832 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14833 })
14834{
14835 if (!lhs.has_value()) {
14836 return false; // RETURN
14837 }
14838
14839 return !rhs.has_value() || *lhs > *rhs;
14840}
14841
14842template <class t_LHS_TYPE, class t_RHS_TYPE>
14845 const bsl::optional<t_RHS_TYPE>& rhs)
14846 BSLSTL_OPTIONAL_REQUIRES(requires {
14847 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14848 })
14849{
14850 if (!lhs.has_value()) {
14851 return true; // RETURN
14852 }
14853
14854 return rhs.has_value() && *lhs <= *rhs;
14855}
14856
14857template <class t_LHS_TYPE, class t_RHS_TYPE>
14860 const bsl::optional<t_RHS_TYPE>& rhs)
14861 BSLSTL_OPTIONAL_REQUIRES(requires {
14862 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14863 })
14864{
14865 if (!rhs.has_value()) {
14866 return true; // RETURN
14867 }
14868 return lhs.has_value() && *lhs >= *rhs;
14869}
14870
14871// comparison with 'nullopt_t'
14872
14873template <class t_TYPE>
14874inline
14876 const bsl::optional<t_TYPE>& value,
14878{
14879 return !value.has_value();
14880}
14881
14882#if !(defined(BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON) && \
14883 defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS))
14884template <class t_TYPE>
14885inline
14887 const bsl::nullopt_t&,
14889{
14890 return !value.has_value();
14891}
14892
14893template <class t_TYPE>
14894inline
14896 const bsl::optional<t_TYPE>& value,
14898{
14899 return value.has_value();
14900}
14901
14902template <class t_TYPE>
14903inline
14905 const bsl::nullopt_t&,
14907{
14908 return value.has_value();
14909}
14910
14911template <class t_TYPE>
14912inline
14914 const bsl::optional<t_TYPE>&,
14916{
14917 return false;
14918}
14919
14920template <class t_TYPE>
14921inline
14923 const bsl::nullopt_t&,
14925{
14926 return value.has_value();
14927}
14928
14929template <class t_TYPE>
14930inline
14932 const bsl::optional<t_TYPE>& value,
14934{
14935 return value.has_value();
14936}
14937
14938template <class t_TYPE>
14939inline
14941 const bsl::nullopt_t&,
14943{
14944 return false;
14945}
14946
14947template <class t_TYPE>
14948inline
14950 const bsl::optional<t_TYPE>& value,
14952{
14953 return !value.has_value();
14954}
14955
14956template <class t_TYPE>
14957inline
14959 const bsl::nullopt_t&,
14961{
14962 return true;
14963}
14964
14965template <class t_TYPE>
14966inline
14968 const bsl::optional<t_TYPE>&,
14970{
14971 return true;
14972}
14973
14974template <class t_TYPE>
14975inline
14977 const bsl::nullopt_t&,
14979{
14980 return !value.has_value();
14981}
14982#endif // !(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS &&
14983 // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON)
14984
14985// comparison with 'value_type'
14986
14987template <class t_LHS_TYPE, class t_RHS_TYPE>
14989bool operator==(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
14991 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
14992 && requires {
14993 { *lhs == rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
14994 })
14995{
14996 return lhs.has_value() && *lhs == rhs;
14997}
14998
14999template <class t_LHS_TYPE, class t_RHS_TYPE>
15001bool operator==(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15003 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15004 && requires {
15005 { lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15006 })
15007{
15008 return rhs.has_value() && lhs == *rhs;
15009}
15010
15011template <class t_LHS_TYPE, class t_RHS_TYPE>
15013bool operator!=(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
15015 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
15016 && requires {
15017 { *lhs != rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15018 })
15019{
15020 return !lhs.has_value() || *lhs != rhs;
15021}
15022
15023template <class t_LHS_TYPE, class t_RHS_TYPE>
15025bool operator!=(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15027 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15028 && requires {
15029 { lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15030 })
15031{
15032 return !rhs.has_value() || lhs != *rhs;
15033}
15034
15035template <class t_LHS_TYPE, class t_RHS_TYPE>
15037bool operator<(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
15039 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
15040 && requires {
15041 { *lhs < rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15042 })
15043{
15044 return !lhs.has_value() || *lhs < rhs;
15045}
15046
15047template <class t_LHS_TYPE, class t_RHS_TYPE>
15049bool operator<(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15051 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15052 && requires {
15053 { lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15054 })
15055{
15056 return rhs.has_value() && lhs < *rhs;
15057}
15058
15059template <class t_LHS_TYPE, class t_RHS_TYPE>
15061bool operator>(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
15063 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
15064 && requires {
15065 { *lhs > rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15066 })
15067{
15068 return lhs.has_value() && *lhs > rhs;
15069}
15070
15071template <class t_LHS_TYPE, class t_RHS_TYPE>
15073bool operator>(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15075 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15076 && requires {
15077 { lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15078 })
15079{
15080 return !rhs.has_value() || lhs > *rhs;
15081}
15082
15083template <class t_LHS_TYPE, class t_RHS_TYPE>
15085bool operator<=(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
15087 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
15088 && requires {
15089 { *lhs <= rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15090 })
15091{
15092 return !lhs.has_value() || *lhs <= rhs;
15093}
15094
15095template <class t_LHS_TYPE, class t_RHS_TYPE>
15097bool operator<=(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15099 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15100 && requires {
15101 { lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15102 })
15103{
15104 return rhs.has_value() && lhs <= *rhs;
15105}
15106
15107template <class t_LHS_TYPE, class t_RHS_TYPE>
15109bool operator>=(const bsl::optional<t_LHS_TYPE>& lhs, const t_RHS_TYPE& rhs)
15111 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
15112 && requires {
15113 { *lhs >= rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15114 })
15115{
15116 return lhs.has_value() && *lhs >= rhs;
15117}
15118
15119template <class t_LHS_TYPE, class t_RHS_TYPE>
15121bool operator>=(const t_LHS_TYPE& lhs, const bsl::optional<t_RHS_TYPE>& rhs)
15123 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
15124 && requires {
15125 { lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15126 })
15127{
15128 return !rhs.has_value() || lhs >= *rhs;
15129}
15130
15131#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
15132 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
15133template <class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
15135compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
15136 const bsl::optional<t_LHS>& lhs,
15137 const bsl::optional<t_RHS>& rhs)
15138{
15139 const bool lhs_has_value = lhs.has_value(),
15140 rhs_has_value = rhs.has_value();
15141 if (lhs_has_value && rhs_has_value) {
15142 return *lhs <=> *rhs;
15143 }
15144 return lhs_has_value <=> rhs_has_value;
15145}
15146
15147template <class t_LHS, class t_RHS>
15148requires (!BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS>) &&
15149 three_way_comparable_with<t_LHS, t_RHS>
15151compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
15152 const bsl::optional<t_LHS>& lhs,
15153 const t_RHS& rhs)
15154{
15155 if (lhs) {
15156 return *lhs <=> rhs;
15157 }
15158 return strong_ordering::less;
15159}
15160
15161template <class t_TYPE>
15163strong_ordering operator<=>(const bsl::optional<t_TYPE>& value,
15165{
15166 return value.has_value() <=> false;
15167}
15168
15169template <class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
15171compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
15172 const bsl::optional<t_LHS>& lhs,
15173 const std::optional<t_RHS>& rhs)
15174{
15175 const bool lhs_has_value = lhs.has_value(),
15176 rhs_has_value = rhs.has_value();
15177 if (lhs_has_value && rhs_has_value) {
15178 return *lhs <=> *rhs;
15179 }
15180 return lhs_has_value <=> rhs_has_value;
15181}
15182#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON &&
15183 // BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
15184
15185# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
15186template <class t_TYPE>
15187inline
15189 void>::type
15190swap(bsl::optional<t_TYPE>& lhs, std::optional<t_TYPE>& rhs)
15191{
15192 lhs.swap(rhs);
15193}
15194
15195template <class t_TYPE>
15198 void>::type
15199swap(std::optional<t_TYPE>& lhs, bsl::optional<t_TYPE>& rhs)
15200{
15201 lhs.swap(rhs);
15202}
15203
15204// comparison with 'std::optional'
15205
15206template <class t_LHS_TYPE, class t_RHS_TYPE>
15207constexpr
15209 const std::optional<t_RHS_TYPE>& rhs)
15210 BSLSTL_OPTIONAL_REQUIRES(requires {
15211 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15212 })
15213{
15214 if (lhs.has_value() && rhs.has_value()) {
15215 return *lhs == *rhs;
15216 }
15217 return lhs.has_value() == rhs.has_value();
15218}
15219
15220template <class t_LHS_TYPE, class t_RHS_TYPE>
15221constexpr
15222bool operator==(const std::optional<t_LHS_TYPE>& lhs,
15223 const bsl::optional<t_RHS_TYPE>& rhs)
15224 BSLSTL_OPTIONAL_REQUIRES(requires {
15225 { *lhs == *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15226 })
15227{
15228 if (lhs.has_value() && rhs.has_value()) {
15229 return *lhs == *rhs;
15230 }
15231 return lhs.has_value() == rhs.has_value();
15232}
15233
15234template <class t_LHS_TYPE, class t_RHS_TYPE>
15235constexpr
15237 const std::optional<t_RHS_TYPE>& rhs)
15238 BSLSTL_OPTIONAL_REQUIRES(requires {
15239 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15240 })
15241{
15242 if (lhs.has_value() && rhs.has_value()) {
15243 return *lhs != *rhs;
15244 }
15245
15246 return lhs.has_value() != rhs.has_value();
15247}
15248
15249template <class t_LHS_TYPE, class t_RHS_TYPE>
15250constexpr
15251bool operator!=(const std::optional<t_LHS_TYPE>& lhs,
15252 const bsl::optional<t_RHS_TYPE>& rhs)
15253 BSLSTL_OPTIONAL_REQUIRES(requires {
15254 { *lhs != *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15255 })
15256{
15257 if (lhs.has_value() && rhs.has_value()) {
15258 return *lhs != *rhs;
15259 }
15260
15261 return lhs.has_value() != rhs.has_value();
15262}
15263
15264template <class t_LHS_TYPE, class t_RHS_TYPE>
15265constexpr
15266bool operator<(const bsl::optional<t_LHS_TYPE>& lhs,
15267 const std::optional<t_RHS_TYPE>& rhs)
15268 BSLSTL_OPTIONAL_REQUIRES(requires {
15269 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15270 })
15271{
15272 if (!rhs.has_value()) {
15273 return false; // RETURN
15274 }
15275
15276 return !lhs.has_value() || *lhs < *rhs;
15277}
15278
15279template <class t_LHS_TYPE, class t_RHS_TYPE>
15280constexpr
15281bool operator<(const std::optional<t_LHS_TYPE>& lhs,
15282 const bsl::optional<t_RHS_TYPE>& rhs)
15283 BSLSTL_OPTIONAL_REQUIRES(requires {
15284 { *lhs < *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15285 })
15286{
15287 if (!rhs.has_value()) {
15288 return false; // RETURN
15289 }
15290
15291 return !lhs.has_value() || *lhs < *rhs;
15292}
15293
15294template <class t_LHS_TYPE, class t_RHS_TYPE>
15295constexpr
15296bool operator>(const bsl::optional<t_LHS_TYPE>& lhs,
15297 const std::optional<t_RHS_TYPE>& rhs)
15298 BSLSTL_OPTIONAL_REQUIRES(requires {
15299 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15300 })
15301{
15302 if (!lhs.has_value()) {
15303 return false; // RETURN
15304 }
15305
15306 return !rhs.has_value() || *lhs > *rhs;
15307}
15308
15309template <class t_LHS_TYPE, class t_RHS_TYPE>
15310constexpr
15311bool operator>(const std::optional<t_LHS_TYPE>& lhs,
15312 const bsl::optional<t_RHS_TYPE>& rhs)
15313 BSLSTL_OPTIONAL_REQUIRES(requires {
15314 { *lhs > *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15315 })
15316{
15317 if (!lhs.has_value()) {
15318 return false; // RETURN
15319 }
15320
15321 return !rhs.has_value() || *lhs > *rhs;
15322}
15323
15324template <class t_LHS_TYPE, class t_RHS_TYPE>
15325constexpr
15327 const std::optional<t_RHS_TYPE>& rhs)
15328 BSLSTL_OPTIONAL_REQUIRES(requires {
15329 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15330 })
15331{
15332 if (!lhs.has_value()) {
15333 return true; // RETURN
15334 }
15335
15336 return rhs.has_value() && *lhs <= *rhs;
15337}
15338
15339template <class t_LHS_TYPE, class t_RHS_TYPE>
15340constexpr
15341bool operator<=(const std::optional<t_LHS_TYPE>& lhs,
15342 const bsl::optional<t_RHS_TYPE>& rhs)
15343 BSLSTL_OPTIONAL_REQUIRES(requires {
15344 { *lhs <= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15345 })
15346{
15347 if (!lhs.has_value()) {
15348 return true; // RETURN
15349 }
15350
15351 return rhs.has_value() && *lhs <= *rhs;
15352}
15353
15354template <class t_LHS_TYPE, class t_RHS_TYPE>
15355constexpr
15357 const std::optional<t_RHS_TYPE>& rhs)
15358 BSLSTL_OPTIONAL_REQUIRES(requires {
15359 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15360 })
15361{
15362 if (!rhs.has_value()) {
15363 return true; // RETURN
15364 }
15365 return lhs.has_value() && *lhs >= *rhs;
15366}
15367
15368template <class t_LHS_TYPE, class t_RHS_TYPE>
15369constexpr
15370bool operator>=(const std::optional<t_LHS_TYPE>& lhs,
15371 const bsl::optional<t_RHS_TYPE>& rhs)
15372 BSLSTL_OPTIONAL_REQUIRES(requires {
15373 { *lhs >= *rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
15374 })
15375{
15376 if (!rhs.has_value()) {
15377 return true; // RETURN
15378 }
15379 return lhs.has_value() && *lhs >= *rhs;
15380}
15381# endif // BSLSTL_OPTIONAL_USES_STD_ALIASES
15382
15383template <class t_TYPE>
15386 const typename bsl::optional<
15387 typename bsl::decay<t_TYPE>::type>::allocator_type& alloc,
15389{
15391 bsl::allocator_arg,
15392 alloc,
15394 BSLS_COMPILERFEATURES_FORWARD(t_TYPE, rhs));
15395}
15396
15397#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
15398// {{{ BEGIN GENERATED CODE
15399// Command line: sim_cpp11_features.pl bslstl_optional.h
15400#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
15401#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
15402#endif
15403#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_U
15404#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_U BSLSTL_OPTIONAL_VARIADIC_LIMIT
15405#endif
15406#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 0
15407template <class t_TYPE>
15410 typename bsl::optional<t_TYPE>::allocator_type const& alloc)
15411{
15412 return bsl::optional<t_TYPE>(
15413 bsl::allocator_arg,
15414 alloc,
15416}
15417#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 0
15418
15419#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 1
15420template <class t_TYPE, class t_ARGS_01>
15423 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15424 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
15425{
15426 return bsl::optional<t_TYPE>(
15427 bsl::allocator_arg,
15428 alloc,
15430 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
15431}
15432#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 1
15433
15434#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 2
15435template <class t_TYPE, class t_ARGS_01,
15436 class t_ARGS_02>
15439 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15440 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15441 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
15442{
15443 return bsl::optional<t_TYPE>(
15444 bsl::allocator_arg,
15445 alloc,
15447 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15448 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
15449}
15450#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 2
15451
15452#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 3
15453template <class t_TYPE, class t_ARGS_01,
15454 class t_ARGS_02,
15455 class t_ARGS_03>
15458 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15459 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15460 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15461 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
15462{
15463 return bsl::optional<t_TYPE>(
15464 bsl::allocator_arg,
15465 alloc,
15467 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15468 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15469 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
15470}
15471#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 3
15472
15473#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 4
15474template <class t_TYPE, class t_ARGS_01,
15475 class t_ARGS_02,
15476 class t_ARGS_03,
15477 class t_ARGS_04>
15480 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15481 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15482 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15483 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15484 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
15485{
15486 return bsl::optional<t_TYPE>(
15487 bsl::allocator_arg,
15488 alloc,
15490 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15491 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15492 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15493 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
15494}
15495#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 4
15496
15497#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 5
15498template <class t_TYPE, class t_ARGS_01,
15499 class t_ARGS_02,
15500 class t_ARGS_03,
15501 class t_ARGS_04,
15502 class t_ARGS_05>
15505 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15506 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15507 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15508 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15509 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15510 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
15511{
15512 return bsl::optional<t_TYPE>(
15513 bsl::allocator_arg,
15514 alloc,
15516 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15517 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15518 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15519 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15520 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
15521}
15522#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 5
15523
15524#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 6
15525template <class t_TYPE, class t_ARGS_01,
15526 class t_ARGS_02,
15527 class t_ARGS_03,
15528 class t_ARGS_04,
15529 class t_ARGS_05,
15530 class t_ARGS_06>
15533 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15534 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15535 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15536 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15537 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15538 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15539 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
15540{
15541 return bsl::optional<t_TYPE>(
15542 bsl::allocator_arg,
15543 alloc,
15545 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15546 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15547 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15548 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15549 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15550 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
15551}
15552#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 6
15553
15554#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 7
15555template <class t_TYPE, class t_ARGS_01,
15556 class t_ARGS_02,
15557 class t_ARGS_03,
15558 class t_ARGS_04,
15559 class t_ARGS_05,
15560 class t_ARGS_06,
15561 class t_ARGS_07>
15564 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15565 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15566 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15567 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15568 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15569 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15570 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15571 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
15572{
15573 return bsl::optional<t_TYPE>(
15574 bsl::allocator_arg,
15575 alloc,
15577 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15578 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15579 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15580 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15581 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15582 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15583 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
15584}
15585#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 7
15586
15587#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 8
15588template <class t_TYPE, class t_ARGS_01,
15589 class t_ARGS_02,
15590 class t_ARGS_03,
15591 class t_ARGS_04,
15592 class t_ARGS_05,
15593 class t_ARGS_06,
15594 class t_ARGS_07,
15595 class t_ARGS_08>
15598 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15599 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15600 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15601 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15602 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15603 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15604 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15605 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
15606 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
15607{
15608 return bsl::optional<t_TYPE>(
15609 bsl::allocator_arg,
15610 alloc,
15612 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15613 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15614 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15615 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15616 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15617 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15618 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
15619 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
15620}
15621#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 8
15622
15623#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 9
15624template <class t_TYPE, class t_ARGS_01,
15625 class t_ARGS_02,
15626 class t_ARGS_03,
15627 class t_ARGS_04,
15628 class t_ARGS_05,
15629 class t_ARGS_06,
15630 class t_ARGS_07,
15631 class t_ARGS_08,
15632 class t_ARGS_09>
15635 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15636 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15637 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15638 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15639 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15640 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15641 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15642 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
15643 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
15644 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
15645{
15646 return bsl::optional<t_TYPE>(
15647 bsl::allocator_arg,
15648 alloc,
15650 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15651 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15652 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15653 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15654 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15655 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15656 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
15657 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
15658 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
15659}
15660#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 9
15661
15662#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 10
15663template <class t_TYPE, class t_ARGS_01,
15664 class t_ARGS_02,
15665 class t_ARGS_03,
15666 class t_ARGS_04,
15667 class t_ARGS_05,
15668 class t_ARGS_06,
15669 class t_ARGS_07,
15670 class t_ARGS_08,
15671 class t_ARGS_09,
15672 class t_ARGS_10>
15675 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15676 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15677 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15678 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15679 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15680 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15681 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15682 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
15683 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
15684 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
15685 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
15686{
15687 return bsl::optional<t_TYPE>(
15688 bsl::allocator_arg,
15689 alloc,
15691 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15692 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15693 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15694 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15695 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15696 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15697 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
15698 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
15699 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
15700 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
15701}
15702#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_U >= 10
15703
15704#else
15705// The generated code below is a workaround for the absence of perfect
15706// forwarding in some compilers.
15707template <class t_TYPE, class... t_ARGS>
15710 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15711 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
15712{
15713 return bsl::optional<t_TYPE>(
15714 bsl::allocator_arg,
15715 alloc,
15717 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
15718}
15719// }}} END GENERATED CODE
15720#endif
15721
15722#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
15723// {{{ BEGIN GENERATED CODE
15724// Command line: sim_cpp11_features.pl bslstl_optional.h
15725#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
15726#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
15727#endif
15728#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_V
15729#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_V BSLSTL_OPTIONAL_VARIADIC_LIMIT
15730#endif
15731# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
15732#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 0
15733template <class t_TYPE, class t_INIT_LIST_TYPE>
15736 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15737 std::initializer_list<t_INIT_LIST_TYPE> il)
15738{
15739 return bsl::optional<t_TYPE>(
15740 bsl::allocator_arg,
15741 alloc,
15743 il);
15744}
15745#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 0
15746
15747#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 1
15748template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01>
15751 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15752 std::initializer_list<t_INIT_LIST_TYPE> il,
15753 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
15754{
15755 return bsl::optional<t_TYPE>(
15756 bsl::allocator_arg,
15757 alloc,
15759 il,
15760 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
15761}
15762#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 1
15763
15764#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 2
15765template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15766 class t_ARGS_02>
15769 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15770 std::initializer_list<t_INIT_LIST_TYPE> il,
15771 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15772 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
15773{
15774 return bsl::optional<t_TYPE>(
15775 bsl::allocator_arg,
15776 alloc,
15778 il,
15779 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15780 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
15781}
15782#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 2
15783
15784#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 3
15785template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15786 class t_ARGS_02,
15787 class t_ARGS_03>
15790 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15791 std::initializer_list<t_INIT_LIST_TYPE> il,
15792 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15793 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15794 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
15795{
15796 return bsl::optional<t_TYPE>(
15797 bsl::allocator_arg,
15798 alloc,
15800 il,
15801 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15802 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15803 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
15804}
15805#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 3
15806
15807#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 4
15808template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15809 class t_ARGS_02,
15810 class t_ARGS_03,
15811 class t_ARGS_04>
15814 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15815 std::initializer_list<t_INIT_LIST_TYPE> il,
15816 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15817 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15818 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15819 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
15820{
15821 return bsl::optional<t_TYPE>(
15822 bsl::allocator_arg,
15823 alloc,
15825 il,
15826 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15827 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15828 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15829 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
15830}
15831#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 4
15832
15833#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 5
15834template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15835 class t_ARGS_02,
15836 class t_ARGS_03,
15837 class t_ARGS_04,
15838 class t_ARGS_05>
15841 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15842 std::initializer_list<t_INIT_LIST_TYPE> il,
15843 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15844 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15845 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15846 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15847 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
15848{
15849 return bsl::optional<t_TYPE>(
15850 bsl::allocator_arg,
15851 alloc,
15853 il,
15854 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15855 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15856 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15857 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15858 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
15859}
15860#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 5
15861
15862#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 6
15863template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15864 class t_ARGS_02,
15865 class t_ARGS_03,
15866 class t_ARGS_04,
15867 class t_ARGS_05,
15868 class t_ARGS_06>
15871 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15872 std::initializer_list<t_INIT_LIST_TYPE> il,
15873 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15874 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15875 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15876 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15877 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15878 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
15879{
15880 return bsl::optional<t_TYPE>(
15881 bsl::allocator_arg,
15882 alloc,
15884 il,
15885 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15886 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15887 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15888 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15889 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15890 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
15891}
15892#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 6
15893
15894#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 7
15895template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15896 class t_ARGS_02,
15897 class t_ARGS_03,
15898 class t_ARGS_04,
15899 class t_ARGS_05,
15900 class t_ARGS_06,
15901 class t_ARGS_07>
15904 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15905 std::initializer_list<t_INIT_LIST_TYPE> il,
15906 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15907 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15908 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15909 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15910 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15911 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15912 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
15913{
15914 return bsl::optional<t_TYPE>(
15915 bsl::allocator_arg,
15916 alloc,
15918 il,
15919 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15920 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15921 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15922 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15923 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15924 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15925 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
15926}
15927#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 7
15928
15929#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 8
15930template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15931 class t_ARGS_02,
15932 class t_ARGS_03,
15933 class t_ARGS_04,
15934 class t_ARGS_05,
15935 class t_ARGS_06,
15936 class t_ARGS_07,
15937 class t_ARGS_08>
15940 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15941 std::initializer_list<t_INIT_LIST_TYPE> il,
15942 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15943 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15944 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15945 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15946 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15947 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15948 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
15949 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
15950{
15951 return bsl::optional<t_TYPE>(
15952 bsl::allocator_arg,
15953 alloc,
15955 il,
15956 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15957 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15958 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15959 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
15960 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
15961 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
15962 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
15963 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
15964}
15965#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 8
15966
15967#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 9
15968template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
15969 class t_ARGS_02,
15970 class t_ARGS_03,
15971 class t_ARGS_04,
15972 class t_ARGS_05,
15973 class t_ARGS_06,
15974 class t_ARGS_07,
15975 class t_ARGS_08,
15976 class t_ARGS_09>
15979 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
15980 std::initializer_list<t_INIT_LIST_TYPE> il,
15981 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
15982 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
15983 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
15984 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
15985 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
15986 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
15987 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
15988 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
15989 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
15990{
15991 return bsl::optional<t_TYPE>(
15992 bsl::allocator_arg,
15993 alloc,
15995 il,
15996 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
15997 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
15998 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
15999 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16000 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16001 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16002 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16003 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16004 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
16005}
16006#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 9
16007
16008#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 10
16009template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16010 class t_ARGS_02,
16011 class t_ARGS_03,
16012 class t_ARGS_04,
16013 class t_ARGS_05,
16014 class t_ARGS_06,
16015 class t_ARGS_07,
16016 class t_ARGS_08,
16017 class t_ARGS_09,
16018 class t_ARGS_10>
16021 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
16022 std::initializer_list<t_INIT_LIST_TYPE> il,
16023 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16024 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16025 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16026 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16027 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16028 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16029 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16030 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
16031 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
16032 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
16033{
16034 return bsl::optional<t_TYPE>(
16035 bsl::allocator_arg,
16036 alloc,
16038 il,
16039 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16040 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16041 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16042 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16043 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16044 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16045 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16046 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16047 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
16048 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
16049}
16050#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_V >= 10
16051
16052# endif
16053#else
16054// The generated code below is a workaround for the absence of perfect
16055// forwarding in some compilers.
16056# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
16057template <class t_TYPE, class t_INIT_LIST_TYPE, class... t_ARGS>
16060 typename bsl::optional<t_TYPE>::allocator_type const& alloc,
16061 std::initializer_list<t_INIT_LIST_TYPE> il,
16062 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
16063{
16064 return bsl::optional<t_TYPE>(
16065 bsl::allocator_arg,
16066 alloc,
16068 il,
16069 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
16070}
16071# endif
16072// }}} END GENERATED CODE
16073#endif
16074
16075template <class t_TYPE>
16078{
16080 BSLS_COMPILERFEATURES_FORWARD(t_TYPE, rhs));
16081}
16082
16083template <class t_TYPE>
16085{
16087}
16088
16089#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
16090// {{{ BEGIN GENERATED CODE
16091// Command line: sim_cpp11_features.pl bslstl_optional.h
16092#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT
16093#define BSLSTL_OPTIONAL_VARIADIC_LIMIT 10
16094#endif
16095#ifndef BSLSTL_OPTIONAL_VARIADIC_LIMIT_W
16096#define BSLSTL_OPTIONAL_VARIADIC_LIMIT_W BSLSTL_OPTIONAL_VARIADIC_LIMIT
16097#endif
16098#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 0
16099template <class t_TYPE, class t_ARG>
16102{
16103 return bsl::optional<t_TYPE>(
16105 BSLS_COMPILERFEATURES_FORWARD(t_ARG, arg));
16106}
16107#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 0
16108
16109#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 1
16110template <class t_TYPE, class t_ARG, class t_ARGS_01>
16113 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
16114{
16115 return bsl::optional<t_TYPE>(
16118 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
16119}
16120#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 1
16121
16122#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 2
16123template <class t_TYPE, class t_ARG, class t_ARGS_01,
16124 class t_ARGS_02>
16127 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16128 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
16129{
16130 return bsl::optional<t_TYPE>(
16133 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16134 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
16135}
16136#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 2
16137
16138#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 3
16139template <class t_TYPE, class t_ARG, class t_ARGS_01,
16140 class t_ARGS_02,
16141 class t_ARGS_03>
16144 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16145 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16146 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
16147{
16148 return bsl::optional<t_TYPE>(
16151 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16152 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16153 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
16154}
16155#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 3
16156
16157#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 4
16158template <class t_TYPE, class t_ARG, class t_ARGS_01,
16159 class t_ARGS_02,
16160 class t_ARGS_03,
16161 class t_ARGS_04>
16164 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16165 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16166 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16167 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
16168{
16169 return bsl::optional<t_TYPE>(
16172 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16173 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16174 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16175 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
16176}
16177#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 4
16178
16179#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 5
16180template <class t_TYPE, class t_ARG, class t_ARGS_01,
16181 class t_ARGS_02,
16182 class t_ARGS_03,
16183 class t_ARGS_04,
16184 class t_ARGS_05>
16187 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16188 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16189 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16190 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16191 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
16192{
16193 return bsl::optional<t_TYPE>(
16196 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16197 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16198 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16199 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16200 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
16201}
16202#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 5
16203
16204#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 6
16205template <class t_TYPE, class t_ARG, class t_ARGS_01,
16206 class t_ARGS_02,
16207 class t_ARGS_03,
16208 class t_ARGS_04,
16209 class t_ARGS_05,
16210 class t_ARGS_06>
16213 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16214 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16215 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16216 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16217 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16218 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
16219{
16220 return bsl::optional<t_TYPE>(
16223 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16224 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16225 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16226 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16227 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16228 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
16229}
16230#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 6
16231
16232#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 7
16233template <class t_TYPE, class t_ARG, class t_ARGS_01,
16234 class t_ARGS_02,
16235 class t_ARGS_03,
16236 class t_ARGS_04,
16237 class t_ARGS_05,
16238 class t_ARGS_06,
16239 class t_ARGS_07>
16242 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16243 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16244 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16245 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16246 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16247 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16248 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
16249{
16250 return bsl::optional<t_TYPE>(
16253 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16254 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16255 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16256 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16257 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16258 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16259 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
16260}
16261#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 7
16262
16263#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 8
16264template <class t_TYPE, class t_ARG, class t_ARGS_01,
16265 class t_ARGS_02,
16266 class t_ARGS_03,
16267 class t_ARGS_04,
16268 class t_ARGS_05,
16269 class t_ARGS_06,
16270 class t_ARGS_07,
16271 class t_ARGS_08>
16274 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16275 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16276 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16277 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16278 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16279 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16280 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16281 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
16282{
16283 return bsl::optional<t_TYPE>(
16286 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16287 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16288 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16289 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16290 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16291 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16292 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16293 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
16294}
16295#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 8
16296
16297#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 9
16298template <class t_TYPE, class t_ARG, class t_ARGS_01,
16299 class t_ARGS_02,
16300 class t_ARGS_03,
16301 class t_ARGS_04,
16302 class t_ARGS_05,
16303 class t_ARGS_06,
16304 class t_ARGS_07,
16305 class t_ARGS_08,
16306 class t_ARGS_09>
16309 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16310 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16311 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16312 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16313 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16314 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16315 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16316 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
16317 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
16318{
16319 return bsl::optional<t_TYPE>(
16322 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16323 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16324 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16325 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16326 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16327 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16328 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16329 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16330 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
16331}
16332#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 9
16333
16334#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 10
16335template <class t_TYPE, class t_ARG, class t_ARGS_01,
16336 class t_ARGS_02,
16337 class t_ARGS_03,
16338 class t_ARGS_04,
16339 class t_ARGS_05,
16340 class t_ARGS_06,
16341 class t_ARGS_07,
16342 class t_ARGS_08,
16343 class t_ARGS_09,
16344 class t_ARGS_10>
16347 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16348 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16349 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16350 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16351 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16352 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16353 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16354 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
16355 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
16356 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
16357{
16358 return bsl::optional<t_TYPE>(
16361 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16362 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16363 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16364 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16365 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16366 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16367 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16368 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16369 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
16370 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
16371}
16372#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 10
16373
16374
16375# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
16376#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 0
16377template <class t_TYPE, class t_INIT_LIST_TYPE>
16379make_optional(std::initializer_list<t_INIT_LIST_TYPE> il)
16380{
16381 return bsl::optional<t_TYPE>(
16383 il);
16384}
16385#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 0
16386
16387#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 1
16388template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01>
16390make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16391 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01)
16392{
16393 return bsl::optional<t_TYPE>(
16395 il,
16396 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01));
16397}
16398#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 1
16399
16400#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 2
16401template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16402 class t_ARGS_02>
16404make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16405 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16406 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02)
16407{
16408 return bsl::optional<t_TYPE>(
16410 il,
16411 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16412 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02));
16413}
16414#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 2
16415
16416#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 3
16417template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16418 class t_ARGS_02,
16419 class t_ARGS_03>
16421make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16422 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16423 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16424 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03)
16425{
16426 return bsl::optional<t_TYPE>(
16428 il,
16429 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16430 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16431 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03));
16432}
16433#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 3
16434
16435#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 4
16436template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16437 class t_ARGS_02,
16438 class t_ARGS_03,
16439 class t_ARGS_04>
16441make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16442 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16443 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16444 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16445 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04)
16446{
16447 return bsl::optional<t_TYPE>(
16449 il,
16450 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16451 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16452 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16453 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04));
16454}
16455#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 4
16456
16457#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 5
16458template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16459 class t_ARGS_02,
16460 class t_ARGS_03,
16461 class t_ARGS_04,
16462 class t_ARGS_05>
16464make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16465 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16466 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16467 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16468 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16469 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05)
16470{
16471 return bsl::optional<t_TYPE>(
16473 il,
16474 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16475 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16476 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16477 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16478 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05));
16479}
16480#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 5
16481
16482#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 6
16483template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16484 class t_ARGS_02,
16485 class t_ARGS_03,
16486 class t_ARGS_04,
16487 class t_ARGS_05,
16488 class t_ARGS_06>
16490make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16491 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16492 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16493 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16494 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16495 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16496 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06)
16497{
16498 return bsl::optional<t_TYPE>(
16500 il,
16501 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16502 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16503 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16504 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16505 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16506 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06));
16507}
16508#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 6
16509
16510#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 7
16511template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16512 class t_ARGS_02,
16513 class t_ARGS_03,
16514 class t_ARGS_04,
16515 class t_ARGS_05,
16516 class t_ARGS_06,
16517 class t_ARGS_07>
16519make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16520 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16521 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16522 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16523 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16524 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16525 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16526 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07)
16527{
16528 return bsl::optional<t_TYPE>(
16530 il,
16531 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16532 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16533 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16534 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16535 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16536 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16537 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07));
16538}
16539#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 7
16540
16541#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 8
16542template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16543 class t_ARGS_02,
16544 class t_ARGS_03,
16545 class t_ARGS_04,
16546 class t_ARGS_05,
16547 class t_ARGS_06,
16548 class t_ARGS_07,
16549 class t_ARGS_08>
16551make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16552 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16553 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16554 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16555 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16556 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16557 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16558 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16559 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08)
16560{
16561 return bsl::optional<t_TYPE>(
16563 il,
16564 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16565 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16566 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16567 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16568 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16569 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16570 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16571 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08));
16572}
16573#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 8
16574
16575#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 9
16576template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16577 class t_ARGS_02,
16578 class t_ARGS_03,
16579 class t_ARGS_04,
16580 class t_ARGS_05,
16581 class t_ARGS_06,
16582 class t_ARGS_07,
16583 class t_ARGS_08,
16584 class t_ARGS_09>
16586make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16587 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16588 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16589 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16590 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16591 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16592 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16593 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16594 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
16595 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09)
16596{
16597 return bsl::optional<t_TYPE>(
16599 il,
16600 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16601 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16602 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16603 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16604 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16605 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16606 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16607 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16608 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09));
16609}
16610#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 9
16611
16612#if BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 10
16613template <class t_TYPE, class t_INIT_LIST_TYPE, class t_ARGS_01,
16614 class t_ARGS_02,
16615 class t_ARGS_03,
16616 class t_ARGS_04,
16617 class t_ARGS_05,
16618 class t_ARGS_06,
16619 class t_ARGS_07,
16620 class t_ARGS_08,
16621 class t_ARGS_09,
16622 class t_ARGS_10>
16624make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16625 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_01) args_01,
16626 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_02) args_02,
16627 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_03) args_03,
16628 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_04) args_04,
16629 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_05) args_05,
16630 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_06) args_06,
16631 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_07) args_07,
16632 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_08) args_08,
16633 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_09) args_09,
16634 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS_10) args_10)
16635{
16636 return bsl::optional<t_TYPE>(
16638 il,
16639 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_01, args_01),
16640 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_02, args_02),
16641 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_03, args_03),
16642 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_04, args_04),
16643 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_05, args_05),
16644 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_06, args_06),
16645 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_07, args_07),
16646 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_08, args_08),
16647 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_09, args_09),
16648 BSLS_COMPILERFEATURES_FORWARD(t_ARGS_10, args_10));
16649}
16650#endif // BSLSTL_OPTIONAL_VARIADIC_LIMIT_W >= 10
16651
16652# endif
16653#else
16654// The generated code below is a workaround for the absence of perfect
16655// forwarding in some compilers.
16656template <class t_TYPE, class t_ARG, class... t_ARGS>
16659 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
16660{
16661 return bsl::optional<t_TYPE>(
16664 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
16665}
16666
16667# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
16668template <class t_TYPE, class t_INIT_LIST_TYPE, class... t_ARGS>
16670make_optional(std::initializer_list<t_INIT_LIST_TYPE> il,
16671 BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
16672{
16673 return bsl::optional<t_TYPE>(
16675 il,
16676 BSLS_COMPILERFEATURES_FORWARD(t_ARGS, args)...);
16677}
16678# endif
16679// }}} END GENERATED CODE
16680#endif
16681} // close namespace bsl
16682
16683// There is a problem in the standard definition of the is-optional concept
16684// that results in types inheriting from std::optional not being identified
16685// correctly as optional types. The end result is endless recursion evaluating
16686// the requires clause for the spaceship operator when it is implemented
16687// according to the C++20 specification, which happens for GCC 11-14 and
16688// MSVC-2022 prior to MSVC 19.36 when building with C++20 and later. In MSVC
16689// 19.36 Microsoft implemented the solution suggested in LWG-3746, so the
16690// workaround is not required for that and subsequent versions; similarly, the
16691// issue will be resolved in GCC 15 (to be released).
16692//
16693// The issue with the standard is tracked here:
16694// https://cplusplus.github.io/LWG/issue3746
16695//
16696// See DRQS 170388558 for more information
16697//
16698// BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_GNU_WORKAROUND_NEEDED and
16699// BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_MSVC_WORKAROUND_NEEDED are deliberately
16700// exposed to allow their use in higher level optional types (i.e.,
16701// bdlb::NullableValue).
16702
16703// The following hacks prevent compiler crashes, and should only be applied on
16704// compiler versions where the problem is not fixed. The hacks required for
16705// gcc and for MSVC are different due to different standard library
16706// implementations, hence the two distinct macros and implementations.
16707
16708# if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L && \
16709 defined(BSLS_LIBRARYFEATURES_STDCPP_GNU) && \
16710 (11 <= _GLIBCXX_RELEASE && _GLIBCXX_RELEASE <= 14)
16711
16712#define BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_GNU_WORKAROUND_NEEDED
16713
16714namespace std {
16715template<typename _Tp>
16716inline constexpr bool __is_optional_v<bsl::optional<_Tp>> = true;
16717}
16718
16719# endif // BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_GNU_WORKAROUND_NEEDED
16720
16721# if BSLS_COMPILERFEATURES_CPLUSPLUS == 202002L && \
16722 defined(BSLS_PLATFORM_CMP_MSVC) && \
16723 (BSLS_PLATFORM_CMP_VERSION >= 1930 && BSLS_PLATFORM_CMP_VERSION < 1936)
16724 // This workaround is not required from MSVC 19.36 onwards.
16725
16726#define BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_MSVC_WORKAROUND_NEEDED
16727
16728namespace std {
16729template <typename _Tp>
16730inline constexpr bool _Is_specialization_v<bsl::optional<_Tp>, std::optional> =
16731 true;
16732}
16733
16734# endif // BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_MSVC_WORKAROUND_NEEDED
16735
16736#undef BSLSTL_OPTIONAL_CONSTEXPR17
16737#undef BSLSTL_OPTIONAL_CONSTEXPR20
16738#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL
16739#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL
16740#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL
16741#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL
16742#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR
16743#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR
16744#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR
16745#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR
16746#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM
16747#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM
16748#undef BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL
16749#undef BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT
16750#undef BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT
16751#undef BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT
16752#undef BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT
16753#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL
16754#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL
16755#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED
16756#undef BSLSTL_OPTIONAL_ENABLE_IF_NOT_ALLOCATOR_TAG
16757#undef BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG
16758#undef BSLSTL_OPTIONAL_REQUIRES
16759
16760#else // if ! defined(DEFINED_BSLSTL_OPTIONAL_H)
16761# error Not valid except when included from bslstl_optional.h
16762#endif // ! defined(COMPILING_BSLSTL_OPTIONAL_H)
16763
16764#endif // ! defined(INCLUDED_BSLSTL_OPTIONAL_CPP03)
16765
16766// ----------------------------------------------------------------------------
16767// Copyright 2020 Bloomberg Finance L.P.
16768//
16769// Licensed under the Apache License, Version 2.0 (the "License");
16770// you may not use this file except in compliance with the License.
16771// You may obtain a copy of the License at
16772//
16773// http://www.apache.org/licenses/LICENSE-2.0
16774//
16775// Unless required by applicable law or agreed to in writing, software
16776// distributed under the License is distributed on an "AS IS" BASIS,
16777// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16778// See the License for the specific language governing permissions and
16779// limitations under the License.
16780// ----------------------------- END-OF-FILE ----------------------------------
16781
16782/** @} */
16783/** @} */
16784/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
Definition bslma_bslallocator.h:588
decay_imp< U, k_ISARRAY, k_ISFUNC >::type type
Definition bslmf_decay.h:167
Definition bslstl_optional.h:2043
BSLSTL_OPTIONAL_CONSTEXPR20 optional & operator=(bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:5546
BSLSTL_OPTIONAL_CONSTEXPR17 optional() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:5142
Definition bslma_allocator.h:545
Optional_Base()
Definition bslstl_optional.h:3573
t_TYPE & emplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
Definition bslstl_optional.h:3920
Optional_Base & operator=(const Optional_Base &rhs)
Definition bslstl_optional.h:4046
void assignOrEmplace(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) rhs)
Definition bslstl_optional.h:3884
t_TYPE & dereferenceRaw()
Definition bslstl_optional.h:3896
allocator_type AllocType
Definition bslstl_optional.h:944
bool has_value() const BSLS_KEYWORD_NOEXCEPT
Return false if this object is disengaged, and true otherwise.
Definition bslstl_optional.h:4138
t_TYPE value_or(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value) const
Definition bslstl_optional.h:4218
void swap(Optional_Base &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl t_TYPE & value()
Definition bslstl_optional.h:1305
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return allocator used for construction of value_type.
Definition bslstl_optional.h:4129
t_TYPE & operator*()
Definition bslstl_optional.h:4115
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:3943
t_TYPE value_type
Definition bslstl_optional.h:938
bsl::allocator< char > allocator_type
Definition bslstl_optional.h:940
t_TYPE * operator->()
Definition bslstl_optional.h:4086
#define BSLMF_MOVABLEREF_DEDUCE(...)
Definition bslmf_movableref.h:691
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_INVOKE_NORETURN(X)
Definition bsls_assert.h:2101
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_THROW(X)
Definition bsls_exceptionutil.h:374
#define BSLS_NOTHROW_SPEC
Definition bsls_exceptionutil.h:386
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:624
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:651
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:296
#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:429
#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:343
#define BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(DERIVED)
Definition bslstl_optional.h:399
#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, ANY_TYPE)
Definition bslstl_optional.h:369
#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:437
#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( TYPE, ANY_TYPE)
Definition bslstl_optional.h:375
#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE)
Definition bslstl_optional.h:388
#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:335
#define BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(U, V)
Definition bslstl_optional.h:419
#define BSLSTL_OPTIONAL_ENABLE_IF_NOT_ALLOCATOR_TAG(ARG)
Definition bslstl_optional.h:474
#define BSLSTL_OPTIONAL_CONSTEXPR20
Definition bslstl_optional.h:249
#define BSLSTL_OPTIONAL_REQUIRES(EXPR)
Definition bslstl_optional.h:490
#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE)
Definition bslstl_optional.h:394
#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:356
#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE(TYPE, ANY_TYPE)
Definition bslstl_optional.h:465
#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, ANY_TYPE)
Definition bslstl_optional.h:362
#define BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(DERIVED)
Definition bslstl_optional.h:405
#define BSLSTL_OPTIONAL_CONSTEXPR17
Definition bslstl_optional.h:248
#define BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(U, V)
Definition bslstl_optional.h:414
#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE)
Definition bslstl_optional.h:349
#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_FORWARD_REF(TYPE, ANY_TYPE)
Definition bslstl_optional.h:454
#define BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(U, V)
Definition bslstl_optional.h:424
#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( TYPE, ANY_TYPE)
Definition bslstl_optional.h:382
#define BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(U, V)
Definition bslstl_optional.h:409
#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED(TYPE, DERIVED)
Definition bslstl_optional.h:446
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
bool operator<(const MetricId &lhs, const MetricId &rhs)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
bool operator>=(const Guid &lhs, const Guid &rhs)
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const BigEndianInt16 &object)
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
Decimal32 operator*(Decimal32 lhs, Decimal32 rhs)
Definition bdlat_valuetypefunctions.h:939
const nullopt_t nullopt
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition bslstl_array.h:959
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
const in_place_t in_place
ALLOCATOR & lhs
Definition bslstl_string.h:3917
BSLSTL_OPTIONAL_CONSTEXPR17 bool operator==(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator==(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator!=(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator!=(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator<(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator<(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator>(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator>(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator<=(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator<=(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator>=(const bsl::optional< t_LHS_TYPE > &lhs, const t_RHS_TYPE &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP BSLSTL_OPTIONAL_CONSTEXPR17 bool operator>=(const t_LHS_TYPE &lhs, const bsl::optional< t_RHS_TYPE > &rhs) BSLSTL_OPTIONAL_REQUIRES(!BloombergLP bsl::optional< typename bsl::decay< t_TYPE >::type > make_optional(bsl::allocator_arg_t, const typename bsl::optional< typename bsl::decay< t_TYPE >::type >::allocator_type &alloc, BSLS_COMPILERFEATURES_FORWARD_REF(t_TYPE) rhs)
called in constant expressions only if t_LHS_TYPE is not allocator-aware.
Definition bslstl_optional.h:3306
Definition baljsn_encoder_testtypes.h:76
Definition bslstl_algorithm.h:84
Definition bdldfp_decimal.h:5549
Definition bslmf_allocatorargt.h:433
Definition bslmf_enableif.h:530
Definition bslstl_inplace.h:103
Definition bslmf_integralconstant.h:261
Definition bslmf_isnothrowmoveconstructible.h:361
Definition bslstl_optional.h:522
BSLS_KEYWORD_CONSTEXPR nullopt_t(t_TYPE, typename enable_if< is_same< t_TYPE, BloombergLP::bslstl::Optional_NulloptConstructToken >::value, int >::type=0) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:529
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removeconst.h:164
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removereference.h:156
Definition bslmf_isbitwisecopyable.h:298
t_TYPE & emplace(bslma::Allocator *allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
Definition bslstl_optional.h:3430
Optional_DataImp() BSLS_KEYWORD_NOEXCEPT
Create an empty Optional_DataImp object.
Definition bslstl_optional.h:3402
bool hasValue() const BSLS_KEYWORD_NOEXCEPT
Return true if this objects has a value, and false otherwise.
Definition bslstl_optional.h:3507
t_TYPE & value()
Definition bslstl_optional.h:3495
void reset() BSLS_KEYWORD_NOEXCEPT
Destroy the value_type object in d_buffer, if any.
Definition bslstl_optional.h:3464
~Optional_Data()
Destroy the managed value_type object, if it exists.
Definition bslstl_optional.h:3557
Definition bslstl_optional.h:601
BSLS_KEYWORD_CONSTEXPR Optional_OptNoSuchType(int) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:632
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335
TYPE & object()
Definition bsls_objectbuffer.h:352