9#ifndef INCLUDED_BSLSTL_OPTIONAL
10#define INCLUDED_BSLSTL_OPTIONAL
133#include <bslscm_version.h>
178#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
182#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
183# include <type_traits>
186#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
191#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
192# include <initializer_list>
195#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
196# include <functional>
199#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
205# define COMPILING_BSLSTL_OPTIONAL_H
207# undef COMPILING_BSLSTL_OPTIONAL_H
216#if defined (BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY) && \
217 !(defined(BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED) && \
218 (BSLS_LIBRARYFEATURES_FORCE_ABI_ENABLED < 17))
232# define BSLSTL_OPTIONAL_USES_STD_ALIASES
237# define BSLSTL_OPTIONAL_CONSTEXPR17 constexpr
242# ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_BASELINE_LIBRARY
243# define BSLSTL_OPTIONAL_CONSTEXPR20 BSLS_KEYWORD_CONSTEXPR_CPP20
245# define BSLSTL_OPTIONAL_CONSTEXPR20
248# define BSLSTL_OPTIONAL_CONSTEXPR17
249# define BSLSTL_OPTIONAL_CONSTEXPR20
252# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
259#define BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(U, V, DEFAULT) \
260 std::is_constructible<U, V>::value
265#define BSLSTL_OPTIONAL_IS_ASSIGNABLE(U, V, DEFAULT) \
266 std::is_assignable<U, V>::value
270#define BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(U, V, DEFAULT) DEFAULT
272#define BSLSTL_OPTIONAL_IS_ASSIGNABLE(U, V, DEFAULT) DEFAULT
279#define BSLSTL_OPTIONAL_CONVERTS_FROM(TYPE, OPT_TYPE) \
280 (bsl::is_convertible<const OPT_TYPE&, TYPE>::value || \
281 bsl::is_convertible<OPT_TYPE&, TYPE>::value || \
282 bsl::is_convertible<const OPT_TYPE, TYPE>::value || \
283 bsl::is_convertible<OPT_TYPE, TYPE>::value || \
284 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, const OPT_TYPE&, false) || \
285 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, OPT_TYPE&, false) || \
286 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, const OPT_TYPE, false) || \
287 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, OPT_TYPE, false))
292# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
293#define BSLSTL_OPTIONAL_ASSIGNS_FROM(TYPE, OPT_TYPE) \
294 (std::is_assignable<TYPE&, const OPT_TYPE&>::value || \
295 std::is_assignable<TYPE&, OPT_TYPE&>::value || \
296 std::is_assignable<TYPE&, const OPT_TYPE>::value || \
297 std::is_assignable<TYPE&, OPT_TYPE>::value)
302#define BSLSTL_OPTIONAL_ASSIGNS_FROM(TYPE, OPT_TYPE) false
305#define BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
306 BSLSTL_OPTIONAL_CONVERTS_FROM( \
308 bsl::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
310#define BSLSTL_OPTIONAL_ASSIGNS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
311 BSLSTL_OPTIONAL_ASSIGNS_FROM( \
313 bsl::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
315# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
316#define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
317 BSLSTL_OPTIONAL_CONVERTS_FROM( \
319 std::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
321#define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
322 BSLSTL_OPTIONAL_ASSIGNS_FROM( \
324 std::optional<typename bsl::remove_cvref<ANY_TYPE>::type>)
328#define BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false
329#define BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) false
335#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, \
337 typename bsl::enable_if< \
338 !bsl::is_same<TYPE, ANY_TYPE>::value && \
339 !BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) && \
340 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true), \
341 BloombergLP::bslstl::Optional_OptNoSuchType>::type
343#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(TYPE, \
345 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL( \
347 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
349#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, \
351 typename bsl::enable_if< \
352 !BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) && \
353 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true), \
354 BloombergLP::bslstl::Optional_OptNoSuchType>::type
356#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL(TYPE, \
358 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL( \
360 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
362#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, \
364 typename bsl::enable_if< \
365 BloombergLP::bslstl::Optional_PropagatesAllocator<TYPE, \
367 BloombergLP::bslstl::Optional_OptNoSuchType>::type
369#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(TYPE, \
371 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR( \
373 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
375#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
377 typename bsl::enable_if< \
378 !BloombergLP::bslstl::Optional_PropagatesAllocator<TYPE, \
380 BloombergLP::bslstl::Optional_OptNoSuchType>::type
382#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
384 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR( \
386 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
388#define BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE) \
389 typename bsl::enable_if< \
390 BloombergLP::bslstl::Optional_ConstructsFromType<TYPE, \
392 BloombergLP::bslstl::Optional_OptNoSuchType>::type
394#define BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(TYPE, ANY_TYPE) \
395 BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM( \
397 ANY_TYPE) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
399#define BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(DERIVED) \
400 typename bsl::enable_if< \
401 BloombergLP::bslmf::IsAccessibleBaseOf<optional, DERIVED>::value && \
402 !bsl::is_const<DERIVED>::value, \
403 BloombergLP::bslstl::Optional_OptNoSuchType>::type
405#define BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(DERIVED) \
406 BSLSTL_OPTIONAL_DEFINE_IF_DERIVED_FROM_OPTIONAL(DERIVED) = \
407 BloombergLP::bslstl::Optional_OptNoSuchType(0)
409#define BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT(U, V) \
410 typename bsl::enable_if< \
411 !bsl::is_convertible<V, U>::value, \
412 BloombergLP::bslstl::Optional_OptNoSuchType>::type
414#define BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(U, V) \
415 BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT( \
417 V) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
419#define BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT(U, V) \
420 typename bsl::enable_if< \
421 bsl::is_convertible<V, U>::value, \
422 BloombergLP::bslstl::Optional_OptNoSuchType>::type
424#define BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(U, V) \
425 BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT( \
427 V) = BloombergLP::bslstl::Optional_OptNoSuchType(0)
429#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) \
430 typename bsl::enable_if< \
431 !BSLSTL_OPTIONAL_CONVERTS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE) && \
432 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true) && \
433 BSLSTL_OPTIONAL_IS_ASSIGNABLE(TYPE&, ANY_TYPE, true) && \
434 !BSLSTL_OPTIONAL_ASSIGNS_FROM_BSL_OPTIONAL(TYPE, ANY_TYPE), \
435 optional<TYPE> >::type
437#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) \
438 typename bsl::enable_if< \
439 !BSLSTL_OPTIONAL_CONVERTS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE) && \
440 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(TYPE, ANY_TYPE, true) && \
441 BSLSTL_OPTIONAL_IS_ASSIGNABLE(TYPE&, ANY_TYPE, true) && \
442 !BSLSTL_OPTIONAL_ASSIGNS_FROM_STD_OPTIONAL(TYPE, ANY_TYPE), \
443 optional<TYPE> >::type
445# if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
446# define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED(TYPE, DERIVED) \
447 typename bsl::enable_if< \
448 BloombergLP::bslmf::IsAccessibleBaseOf<bsl::optional<TYPE>, \
450 !bsl::is_same<bsl::optional<TYPE>, DERIVED>::value, \
451 optional<TYPE> >::type
454#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_FORWARD_REF(TYPE, ANY_TYPE) \
455 typename bsl::enable_if< \
456 !bsl::is_same<bsl::optional<TYPE>, \
457 typename bsl::remove_cvref<ANY_TYPE>::type>::value && \
458 !(bsl::is_same<TYPE, \
459 typename bsl::decay<ANY_TYPE>::type>::value && \
460 std::is_scalar<TYPE>::value) && \
461 std::is_constructible<TYPE, ANY_TYPE>::value && \
462 std::is_assignable<TYPE, ANY_TYPE>::value, \
463 optional<TYPE> >::type
465#define BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE(TYPE, ANY_TYPE) \
466 typename bsl::enable_if< \
467 !::BloombergLP::bslmf::IsAccessibleBaseOf< \
468 bsl::optional<TYPE>, \
469 typename bsl::remove_cv< \
470 typename ::BloombergLP::bslmf::MovableRefUtil:: \
471 RemoveReference<ANY_TYPE>::type>::type>::value, \
472 optional<TYPE> >::type
474#define BSLSTL_OPTIONAL_ENABLE_IF_NOT_ALLOCATOR_TAG(ARG) \
475 typename bsl::enable_if< \
477 typename bsl::remove_cvref<ARG>::type, \
478 bsl::allocator_arg_t>::value, \
479 optional<t_TYPE> >::type
481#ifdef BSLS_COMPILERFEATURES_SUPPORT_DEFAULT_TEMPLATE_ARGS
482 #define BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(ARG) = ARG
484 #define BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(ARG)
487#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
488 #define BSLSTL_OPTIONAL_REQUIRES(EXPR) requires(EXPR)
490 #define BSLSTL_OPTIONAL_REQUIRES(EXPR)
506# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
508using nullopt_t = std::nullopt_t;
528 template <
class t_TYPE>
532 BloombergLP::bslstl::
533 Optional_NulloptConstructToken>::value,
541# if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES)
543nullopt_t
nullopt(BloombergLP::bslstl::Optional_NulloptConstructToken{});
550template <
class t_TYPE>
566template <
class t_TYPE>
570template <
class t_TYPE>
578# ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
584template <
class t_TYPE>
586: std::is_trivially_destructible<t_TYPE> {
600template <
class t_TYPE>
647template <
class t_TYPE,
class t_ANY_TYPE>
651 bslma::UsesBslmaAllocator<t_TYPE>::value &&
652 bsl::is_const<t_TYPE>::value &&
653 bsl::is_same<t_ANY_TYPE,
654 typename bsl::remove_cv<t_TYPE>::type>::value> {
660template <
class t_TYPE,
class t_ANY_TYPE>
664 !bslmf::IsAccessibleBaseOf<
665 bsl::optional<t_TYPE>,
666 typename bsl::remove_cvref<t_ANY_TYPE>::type>::value &&
667 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
668 bsl::nullopt_t>::value &&
669 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
670 bsl::in_place_t>::value &&
671 !bsl::is_same<typename bsl::remove_cvref<t_ANY_TYPE>::type,
672 bsl::allocator_arg_t>::value &&
673 BSLSTL_OPTIONAL_IS_CONSTRUCTIBLE(t_TYPE, t_ANY_TYPE, true)> {
676#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
686template <
class t_TYPE,
class t_INVOCABLE,
class t_ARG>
687struct Optional_ImmovableHelper {
688 t_INVOCABLE&& invocable;
693 return std::invoke(std::forward<t_INVOCABLE>(invocable),
694 std::forward<t_ARG>(arg));
713#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
717struct Optional_InvokeConstructorTag {
718 explicit Optional_InvokeConstructorTag() =
default;
737template <
class t_TYPE>
758#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
761 template <
class t_INVOCABLE,
class t_ARG>
763 t_INVOCABLE&& invocable,
768#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
772 template <
class... t_ARGS>
776# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
780 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
783 std::initializer_list<t_INIT_LIST_TYPE> initializer_list,
791# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
811# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
816 const t_TYPE&
value()
const &;
817 const t_TYPE&&
value()
const &&;
824 const t_TYPE&
value()
const;
840 bool t_IS_TRIVIALLY_DESTRUCTIBLE =
846#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
861template <
class t_TYPE>
869#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
879#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
880template <
class t_TYPE>
883template <
class t_TYPE>
884void optional_acceptsStdOptional(
const std::optional<t_TYPE>&);
888template <
class t_TYPE>
889concept Optional_ConvertibleToBool =
890 bsl::is_convertible_v<t_TYPE, bool>;
894template <
class t_TYPE>
895concept Optional_DerivedFromBslOptional =
896 requires (
const t_TYPE& t) { optional_acceptsBslOptional(t); };
900template <
class t_TYPE>
901concept Optional_DerivedFromStdOptional =
902 requires (
const t_TYPE& t) { optional_acceptsStdOptional(t); };
906template <
class t_TYPE>
907concept Optional_DerivedFromOptional =
908 Optional_DerivedFromBslOptional<t_TYPE> ||
909 Optional_DerivedFromStdOptional<t_TYPE>;
926template <
class t_TYPE,
927 bool t_USES_BSLMA_ALLOC =
928 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>
948 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
950# ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
957 typedef BloombergLP::bsls::UnspecifiedBool<Optional_Base>
959 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
965 BloombergLP::bslstl::Optional_Data<t_TYPE> d_value;
991 Optional_Base(BloombergLP::bslmf::MovableRef<Optional_Base> original)
998 template <
class t_ANY_TYPE>
1006 template <
class t_ANY_TYPE>
1007 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1015 template <
class t_ANY_TYPE>
1017 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1029 template <
class t_ANY_TYPE>
1031 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1036# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
1041 template <
class t_ANY_TYPE>
1042 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1043 const std::optional<t_ANY_TYPE>& original);
1049 template <
class t_ANY_TYPE>
1050 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1051 std::optional<t_ANY_TYPE>&& original);
1054#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1058 template <
class... t_ARGS>
1061# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1066 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1068 std::initializer_list<t_INIT_LIST_TYPE> il,
1073#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1076 template <
class t_INVOCABLE,
class t_ARG>
1078 t_INVOCABLE&& invocable,
1109 BloombergLP::bslmf::MovableRef<Optional_Base> original);
1114 template <
class t_ANY_TYPE>
1117 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1124 template <
class t_ANY_TYPE>
1127 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1136 template <
class t_ANY_TYPE>
1139 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1142# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
1148 template <
class t_ANY_TYPE>
1151 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1152 const std::optional<t_ANY_TYPE>& original);
1160 template <
class t_ANY_TYPE>
1163 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1164 std::optional<t_ANY_TYPE>&& original);
1167#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1171 template <
class... t_ARGS>
1177# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1181 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1185 std::initializer_list<t_INIT_LIST_TYPE> il,
1196 template <
class t_ANY_TYPE>
1199# ifndef BDE_OMIT_INTERNAL_DEPRECATED
1230 BloombergLP::bslma::UsesBslmaAllocator);
1232 BloombergLP::bslmf::UsesAllocatorArgT);
1235 BloombergLP::bslmf::IsBitwiseMoveable,
1236 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
1239 BloombergLP::bslmf::IsBitwiseCopyable,
1240 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
1244#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1257 template <
class... t_ARGS>
1260# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1274 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1275 t_TYPE&
emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
1292 bsl::is_nothrow_move_constructible<t_TYPE>::
value &&
1293 bsl::is_nothrow_swappable<t_TYPE>::
value);
1295# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1300 t_TYPE&&
value() &&;
1308# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1314 template <
class t_ANY_TYPE>
1316# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1323 template <
class t_ANY_TYPE>
1326 t_ANY_TYPE&&
value) &&;
1340 BloombergLP::bslmf::MovableRef<Optional_Base> rhs);
1348# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1371# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1375 const t_TYPE&
value() const &;
1376 const t_TYPE&&
value() const &&;
1390# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1396 const t_TYPE&& operator*() const &&;
1405# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1411 template <
class t_ANY_TYPE>
1414# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1421 template <
class t_ANY_TYPE>
1433 template <
class t_ANY_TYPE>
1435# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
1442 template <
class t_ANY_TYPE>
1449#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1457 return UnspecifiedBoolUtil::makeValue(
has_value());
1470# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
1473template <
class t_TYPE>
1474class Optional_Base<t_TYPE, false> :
public std::optional<t_TYPE> {
1478 typedef std::optional<t_TYPE> StdOptionalBase;
1500 template <
class t_ANY_TYPE>
1502 Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1503 t_ANY_TYPE&&
value);
1508 template <
class t_ANY_TYPE>
1510 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1511 const Optional_Base<t_ANY_TYPE>& original);
1517 template <
class t_ANY_TYPE>
1519 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1520 Optional_Base<t_ANY_TYPE>&& original);
1522 template <
class t_ANY_TYPE>
1524 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1525 const std::optional<t_ANY_TYPE>& original);
1527 template <
class t_ANY_TYPE>
1529 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1530 std::optional<t_ANY_TYPE>&& original);
1534 template <
class... t_ARGS>
1539 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1542 std::initializer_list<t_INIT_LIST_TYPE> il,
1545#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
1548 template <
class t_INVOCABLE,
class t_ARG>
1550 t_INVOCABLE&& invocable,
1561 template <
class t_ANY_TYPE>
1564 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1567 template <
class t_ANY_TYPE>
1570 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1571 const Optional_Base<t_ANY_TYPE>&);
1573 template <
class t_ANY_TYPE>
1576 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1577 Optional_Base<t_ANY_TYPE>&&);
1579 template <
class t_ANY_TYPE>
1582 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
1583 const std::optional<t_ANY_TYPE>&);
1585 template <
class t_ANY_TYPE>
1588 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
1589 std::optional<t_ANY_TYPE>&&);
1591 template <
class... t_ARGS>
1597 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1601 std::initializer_list<t_INIT_LIST_TYPE>,
1609 template <
class t_ANY_TYPE>
1612# ifndef BDE_OMIT_INTERNAL_DEPRECATED
1644 BloombergLP::bslmf::IsBitwiseMoveable,
1645 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
1648 BloombergLP::bslmf::IsBitwiseCopyable,
1649 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
1663template <
class t_TYPE>
1668 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
1670# ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1677 typedef BloombergLP::bsls::UnspecifiedBool<Optional_Base>
1678 UnspecifiedBoolUtil;
1679 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
1685 BloombergLP::bslstl::Optional_Data<t_TYPE> d_value;
1713 Optional_Base(BloombergLP::bslmf::MovableRef<Optional_Base> original)
1719 template <
class t_ANY_TYPE>
1726 template <
class t_ANY_TYPE>
1727 Optional_Base(BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1734 template <
class t_ANY_TYPE>
1735 Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1738#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1742 template <
class... t_ARGS>
1746# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1750 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1752 std::initializer_list<t_INIT_LIST_TYPE> il,
1768 BloombergLP::bslmf::MovableRef<Optional_Base>);
1770 template <
class t_ANY_TYPE>
1773 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
1776 template <
class t_ANY_TYPE>
1779 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
1782 template <
class t_ANY_TYPE>
1785 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
1788#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1789 template <
class... t_ARGS>
1795# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1796 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1800 std::initializer_list<t_INIT_LIST_TYPE>,
1810 template <
class t_ANY_TYPE>
1813# ifndef BDE_OMIT_INTERNAL_DEPRECATED
1853 BloombergLP::bslmf::IsBitwiseMoveable,
1854 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
1857 BloombergLP::bslmf::IsBitwiseCopyable,
1858 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
1861#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1870 template <
class... t_ARGS>
1873# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1883 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
1884 t_TYPE&
emplace(std::initializer_list<t_INIT_LIST_TYPE> il,
1899 bsl::is_nothrow_move_constructible<t_TYPE>::
value &&
1900 bsl::is_nothrow_swappable<t_TYPE>::
value);
1902# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1907 t_TYPE&&
value() &&;
1915# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1921 template <
class t_ANY_TYPE>
1935 BloombergLP::bslmf::MovableRef<Optional_Base> rhs);
1942# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1954 t_TYPE& operator*();
1962# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1966 const t_TYPE&
value() const &;
1967 const t_TYPE&&
value() const &&;
1972 const t_TYPE& value() const;
1975# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
1981 template <
class t_ANY_TYPE>
1990 template <class t_ANY_TYPE>
2000# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
2006 const t_TYPE&& operator*() const&&;
2012 const t_TYPE& operator*() const;
2015#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
2023 return UnspecifiedBoolUtil::makeValue(
has_value());
2042template <
class t_TYPE>
2043class optional :
public BloombergLP::bslstl::Optional_Base<t_TYPE> {
2046 typedef BloombergLP::bslstl::Optional_Base<t_TYPE> BaseType;
2048 typedef typename BaseType::AllocType AllocType;
2050 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2052#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
2054 template <
class t_ANY_TYPE>
friend class optional;
2060 template <
class t_INVOCABLE,
class t_ARG>
2061 optional(BloombergLP::bslstl::Optional_InvokeConstructorTag ,
2062 t_INVOCABLE&& invocable,
2070 BloombergLP::bslma::UsesBslmaAllocator,
2071 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value);
2074 BloombergLP::bslmf::UsesAllocatorArgT,
2075 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value);
2078 BloombergLP::bslmf::IsBitwiseMoveable,
2079 BloombergLP::bslmf::IsBitwiseMoveable<t_TYPE>::value);
2082 BloombergLP::bslmf::IsBitwiseCopyable,
2083 BloombergLP::bslmf::IsBitwiseCopyable<t_TYPE>::value);
2098#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
2111 template <
class t_DERIVED>
2112 optional(BloombergLP::bslmf::MovableRef<t_DERIVED> original,
2127 template <
class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
2134 template <
class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
2152 template <
class t_ANY_TYPE>
2159 const t_ANY_TYPE&));
2161 template <
class t_ANY_TYPE>
2168 const t_ANY_TYPE&));
2183 template <
class t_ANY_TYPE>
2190 template <
class t_ANY_TYPE>
2197# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
2208 template <
class t_ANY_TYPE>
2210 const std::optional<t_ANY_TYPE>& original,
2217 template <
class t_ANY_TYPE>
2219 const std::optional<t_ANY_TYPE>& original,
2235 template <
class t_ANY_TYPE>
2237 std::optional<t_ANY_TYPE>&& original,
2242 template <
class t_ANY_TYPE>
2244 std::optional<t_ANY_TYPE>&& original,
2250#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2256 template <
class... t_ARGS>
2261# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2267 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
2270 std::initializer_list<t_INIT_LIST_TYPE> il,
2304 template <
class t_DERIVED>
2318 template <
class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
2325 template <
class t_ANY_TYPE BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG(t_TYPE)>
2342 template <
class t_ANY_TYPE>
2351 const t_ANY_TYPE&));
2352 template <
class t_ANY_TYPE>
2361 const t_ANY_TYPE&));
2373 template <
class t_ANY_TYPE>
2381 template <
class t_ANY_TYPE>
2390# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
2400 template <
class t_ANY_TYPE>
2404 const std::optional<t_ANY_TYPE>& original,
2409 const t_ANY_TYPE&));
2410 template <
class t_ANY_TYPE>
2414 const std::optional<t_ANY_TYPE>& original,
2431 template <
class t_ANY_TYPE>
2435 std::optional<t_ANY_TYPE>&& original,
2439 template <
class t_ANY_TYPE>
2443 std::optional<t_ANY_TYPE>&& original,
2449#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
2453 template <
class... t_ARGS>
2459# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2463 template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
2467 std::initializer_list<t_INIT_LIST_TYPE> il,
2485#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
2495 template <
class t_DERIVED>
2497 operator=(BloombergLP::bslmf::MovableRef<t_DERIVED>
rhs);
2509 template <
class t_ANY_TYPE>
2523 template <
class t_ANY_TYPE>
2528#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
2541 template <
class t_ANY_TYPE = t_TYPE>
2566 template <
class t_ANY_TYPE>
2570 template <
class t_ANY_TYPE>
2572 operator=(BloombergLP::bslmf::MovableRef<t_ANY_TYPE>
rhs);
2575#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
2584 template <
class t_ANY_TYPE = t_TYPE>
2597 template <
class t_ANY_TYPE = t_TYPE>
2603#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
2607 #define BSLSTL_OPTIONAL_PROVIDES_MONADICS
2619 template <
class t_FUNC>
constexpr auto transform(t_FUNC&& func) &;
2620 template <
class t_FUNC>
constexpr auto transform(t_FUNC&& func) &&;
2621 template <
class t_FUNC>
constexpr auto transform(t_FUNC&& func)
const &;
2622 template <
class t_FUNC>
constexpr auto transform(t_FUNC&& func)
const &&;
2633 template <
class t_FUNC>
constexpr auto and_then(t_FUNC&& func) &;
2634 template <
class t_FUNC>
constexpr auto and_then(t_FUNC&& func) &&;
2635 template <
class t_FUNC>
constexpr auto and_then(t_FUNC&& func)
const &;
2636 template <
class t_FUNC>
constexpr auto and_then(t_FUNC&& func)
const &&;
2644 template <
class t_FUNC>
2646 enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
2647 std::is_copy_constructible<t_TYPE>>,
2648 optional> or_else(t_FUNC&& func)
const &;
2657 template <
class t_FUNC>
2659 enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
2660 std::is_move_constructible<t_TYPE>>,
2661 optional> or_else(t_FUNC&& func) &&;
2674template <
class t_TYPE>
2679template <
class t_TYPE>
2693# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2698template <
class t_TYPE>
2699optional(t_TYPE) -> optional<t_TYPE>;
2706template <
class t_TYPE,
2708 class =
typename bsl::enable_if_t<
2709 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>,
2710 class =
typename bsl::enable_if_t<
2711 bsl::is_convertible_v<t_ALLOC, bsl::allocator<char>>>
2721template <
class t_TYPE,
2723 class =
typename bsl::enable_if_t<
2724 BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value>,
2725 class =
typename bsl::enable_if_t<
2726 bsl::is_convertible_v<t_ALLOC, bsl::allocator<char>>>
2742template <
class t_TYPE>
2751template <
class t_TYPE>
2761template <
class t_HASHALG,
class t_TYPE>
2762void hashAppend(t_HASHALG& hashAlg,
const optional<t_TYPE>& input);
2772template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2777 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2786template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2791 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2800template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2805 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2814template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2819 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2827template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2832 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2840template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2845 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2853template <
class t_TYPE>
2857#if !(defined(BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON) && \
2858 defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS))
2859template <
class t_TYPE>
2867template <
class t_TYPE>
2871template <
class t_TYPE>
2880template <
class t_TYPE>
2890template <
class t_TYPE>
2898template <
class t_TYPE>
2907template <
class t_TYPE>
2915template <
class t_TYPE>
2924template <
class t_TYPE>
2933template <
class t_TYPE>
2941template <
class t_TYPE>
2956template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2959 const t_RHS_TYPE&
rhs)
2961 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
2963 { *
lhs ==
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2965template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2970 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
2972 {
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2981template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2984 const t_RHS_TYPE&
rhs)
2986 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
2988 { *
lhs !=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
2990template <
class t_LHS_TYPE,
class t_RHS_TYPE>
2995 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
2997 {
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3005template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3009 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
3011 { *
lhs <
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3019template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3023 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
3025 {
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3033template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3037 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
3039 { *
lhs >
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3047template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3051 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
3053 {
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3060template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3064 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
3066 { *
lhs <=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3073template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3077 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
3079 {
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3086template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3090 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
3092 { *
lhs >=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3099template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3103 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
3105 {
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3108#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
3109 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
3115template <
class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
3117compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
3125template <
class t_LHS,
class t_RHS>
3126requires (!BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS>) &&
3127 three_way_comparable_with<t_LHS, t_RHS>
3129compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
3136template <
class t_TYPE>
3145template <
class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
3147compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
3149 const std::optional<t_RHS>&
rhs);
3152# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
3159template <
class t_TYPE>
3163template <
class t_TYPE>
3179template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3180constexpr bool operator==(
const std::optional<t_LHS_TYPE>&
lhs,
3183 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3185template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3187 const std::optional<t_RHS_TYPE>&
rhs)
3189 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3201template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3203 const std::optional<t_RHS_TYPE>&
rhs)
3205 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3207template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3208constexpr bool operator!=(
const std::optional<t_LHS_TYPE>&
lhs,
3211 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3223template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3225 const std::optional<t_RHS_TYPE>&
rhs)
3227 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3229template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3230constexpr bool operator<(
const std::optional<t_LHS_TYPE>&
lhs,
3233 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3244template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3246 const std::optional<t_RHS_TYPE>&
rhs)
3248 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3250template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3251constexpr bool operator>(
const std::optional<t_LHS_TYPE>&
lhs,
3254 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3264template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3266 const std::optional<t_RHS_TYPE>&
rhs)
3268 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3270template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3271constexpr bool operator<=(
const std::optional<t_LHS_TYPE>&
lhs,
3274 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3284template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3286 const std::optional<t_RHS_TYPE>&
rhs)
3288 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3290template <
class t_LHS_TYPE,
class t_RHS_TYPE>
3291constexpr bool operator>=(
const std::optional<t_LHS_TYPE>&
lhs,
3294 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
3304template <
class t_TYPE>
3311#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3318template <
class t_TYPE,
class... t_ARGS>
3324# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3331template <
class t_TYPE,
class t_INIT_LIST_TYPE,
class... t_ARGS>
3335 std::initializer_list<t_INIT_LIST_TYPE> il,
3345template <
class t_TYPE>
3353template <
class t_TYPE>
3356#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3363template <
class t_TYPE,
class t_ARG,
class... t_ARGS>
3368# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3375template <
class t_TYPE,
class t_INIT_LIST_TYPE,
class... t_ARGS>
3401template <
class t_TYPE>
3407#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3408template <
class t_TYPE>
3409template <
class t_INVOCABLE,
class t_ARG>
3412 Optional_InvokeConstructorTag ,
3413 t_INVOCABLE&& invocable,
3418 ::new((
void*)d_buffer.
address()) t_TYPE(
3419 std::invoke(
std::forward<t_INVOCABLE>(invocable),
3420 std::forward<t_ARG>(arg)));
3426#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3427template <
class t_TYPE>
3428template <
class... t_ARGS>
3435 BloombergLP::bslma::ConstructionUtil::construct(
3440 return d_buffer.
object();
3443# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3444template <
class t_TYPE>
3445template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
3448 std::initializer_list<t_INIT_LIST_TYPE> il,
3452 BloombergLP::bslma::ConstructionUtil::construct(
3458 return d_buffer.
object();
3463template <
class t_TYPE>
3468 bslma::DestructionUtil::destroy(d_buffer.
address());
3472# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
3473template <
class t_TYPE>
3480 return d_buffer.
object();
3483template <
class t_TYPE>
3490 return std::move(d_buffer.
object());
3493template <
class t_TYPE>
3500 return d_buffer.
object();
3505template <
class t_TYPE>
3509#ifdef BSLS_PLATFORM_CMP_GNU
3510# pragma GCC diagnostic push
3511# pragma GCC diagnostic ignored "-Warray-bounds"
3514#ifdef BSLS_PLATFORM_CMP_GNU
3515# pragma GCC diagnostic pop
3519# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
3520template <
class t_TYPE>
3527 return d_buffer.
object();
3530template <
class t_TYPE>
3537 return std::move(d_buffer.
object());
3540template <
class t_TYPE>
3547 return d_buffer.
object();
3556template <
class t_TYPE,
bool t_IS_TRIVIALLY_DESTRUCTIBLE>
3571template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3577template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3583template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3588 if (original.has_value()) {
3593template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3596 BloombergLP::bslmf::MovableRef<Optional_Base> original)
3599: d_allocator(MoveUtil::access(original).get_allocator())
3603 if (lvalue.has_value()) {
3604 emplace(MoveUtil::move(*lvalue));
3608template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3609template <
class t_ANY_TYPE>
3612 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
3618template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3619template <
class t_ANY_TYPE>
3622 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
3625 if (original.has_value()) {
3630template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3631template <
class t_ANY_TYPE>
3634 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
3640 if (lvalue.has_value()) {
3641 emplace(MoveUtil::move(*lvalue));
3645template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3646template <
class t_ANY_TYPE>
3649 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
3653: d_allocator(MoveUtil::access(original).get_allocator())
3656 if (lvalue.has_value()) {
3657 emplace(MoveUtil::move(*lvalue));
3661# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
3662template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3663template <
class t_ANY_TYPE>
3666 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
3667 const std::optional<t_ANY_TYPE>& original)
3669 if (original.has_value()) {
3670 emplace(original.value());
3674template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3675template <
class t_ANY_TYPE>
3678 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
3679 std::optional<t_ANY_TYPE>&& original)
3681 if (original.has_value()) {
3682 emplace(std::move(original.value()));
3687#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3688template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3689template <
class... t_ARGS>
3698# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3699template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3700template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
3704 std::initializer_list<t_INIT_LIST_TYPE> il,
3712#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
3713template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3714template <
class t_INVOCABLE,
class t_ARG>
3717 Optional_InvokeConstructorTag tag,
3718 t_INVOCABLE&& invocable,
3720: d_value(tag,
std::forward<t_INVOCABLE>(invocable),
std::forward<t_ARG>(arg))
3721, d_allocator(
bslma::AATypeUtil::getAllocatorFromSubobject<allocator_type>(
3727template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3732: d_allocator(allocator)
3736template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3742: d_allocator(allocator)
3746template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3752: d_allocator(allocator)
3754 if (original.has_value()) {
3759template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3764 BloombergLP::bslmf::MovableRef<Optional_Base> original)
3765: d_allocator(allocator)
3769 if (lvalue.has_value()) {
3770 emplace(MoveUtil::move(*lvalue));
3774template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3775template <
class t_ANY_TYPE>
3780 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
3782: d_allocator(allocator)
3787template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3788template <
class t_ANY_TYPE>
3793 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
3795: d_allocator(allocator)
3797 if (original.has_value()) {
3802template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3803template <
class t_ANY_TYPE>
3808 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
3810: d_allocator(allocator)
3813 if (lvalue.has_value()) {
3814 emplace(MoveUtil::move(*lvalue));
3818# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
3819template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3820template <
class t_ANY_TYPE>
3824 allocator_type allocator,
3825 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
3826 const std::optional<t_ANY_TYPE>& original)
3827: d_allocator(allocator)
3829 if (original.has_value()) {
3834template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3835template <
class t_ANY_TYPE>
3839 allocator_type allocator,
3840 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
3841 std::optional<t_ANY_TYPE>&& original)
3842: d_allocator(allocator)
3844 if (original.has_value()) {
3845 emplace(std::move(original.value()));
3850#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3851template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3852template <
class... t_ARGS>
3864# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3865template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3866template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
3870 allocator_type alloc,
3872 std::initializer_list<t_INIT_LIST_TYPE> il,
3882template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3883template <
class t_ANY_TYPE>
3894# ifndef BDE_OMIT_INTERNAL_DEPRECATED
3895template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3901 return d_value.value();
3905template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3911 return d_value.value();
3916#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3917template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3918template <
class... t_ARGS>
3923 return d_value.emplace(d_allocator.
mechanism(),
3927# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3928template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3929template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
3931 std::initializer_list<t_INIT_LIST_TYPE> il,
3934 return d_value.emplace(d_allocator.
mechanism(),
3941template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3948template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3952 bsl::is_nothrow_swappable<t_TYPE>::value)
3956 if (this->has_value() && other.has_value()) {
3957 BloombergLP::bslalg::SwapUtil::swap(
3961 else if (this->has_value()) {
3962 other.emplace(MoveUtil::move(d_value.value()));
3965 else if (other.has_value()) {
3966 this->emplace(MoveUtil::move(*other));
3971# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
3972template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3979 return d_value.value();
3982template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
3989 return std::move(d_value.value());
3993template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4000 return d_value.value();
4005# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4006template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4007template <
class t_ANY_TYPE>
4010 t_ANY_TYPE&& value) &&
4013 return t_TYPE(std::move(d_value.value()));
4016 return t_TYPE(std::forward<t_ANY_TYPE>(value));
4020# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
4021template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4022template <
class t_ANY_TYPE>
4026 allocator_type allocator,
4027 t_ANY_TYPE&& value) &&
4030 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4032 std::move(d_value.value()));
4035 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4037 std::forward<t_ANY_TYPE>(value));
4043template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4045Optional_Base<t_TYPE, t_USES_BSLMA_ALLOC>&
4048 if (rhs.has_value()) {
4049 if (this->has_value()) {
4050 d_value.
value() = *rhs;
4062template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4066 BloombergLP::bslmf::MovableRef<Optional_Base> rhs)
4070 if (lvalue.has_value()) {
4071 if (this->has_value()) {
4072 d_value.value() = MoveUtil::move(*lvalue);
4075 emplace(MoveUtil::move(*lvalue));
4084template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4093# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4094template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4100 return d_value.value();
4103template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4109 return std::move(d_value.value());
4113template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4119 return d_value.value();
4126template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4135template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4141 return d_value.hasValue();
4144# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4145template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4152 return d_value.value();
4155template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4162 return std::move(d_value.value());
4166template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4173 return d_value.value();
4178# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4179template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4180template <
class t_ANY_TYPE>
4186 return t_TYPE(d_value.value());
4194# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
4195template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4196template <
class t_ANY_TYPE>
4200 allocator_type allocator,
4204 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4205 allocator, d_value.value());
4208 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4215template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4216template <
class t_ANY_TYPE>
4222 return t_TYPE(d_value.value());
4230# ifdef BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION
4231template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4232template <
class t_ANY_TYPE>
4236 allocator_type allocator,
4240 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4241 allocator, d_value.value());
4244 return BloombergLP::bslma::ConstructionUtil::make<t_TYPE>(
4252template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4261# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4262template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4268 return d_value.value();
4271template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4277 return std::move(d_value.value());
4281template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4287 return d_value.value();
4291#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
4292template <
class t_TYPE,
bool t_USES_BSLMA_ALLOC>
4308# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
4310template <
class t_TYPE>
4316template <
class t_TYPE>
4322template <
class t_TYPE>
4323template <
class t_ANY_TYPE>
4326 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
4328: StdOptionalBase(
std::forward<t_ANY_TYPE>(value))
4332template <
class t_TYPE>
4333template <
class t_ANY_TYPE>
4336 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
4337 const Optional_Base<t_ANY_TYPE>& original)
4339 if (original.has_value()) {
4340 this->emplace(original.value());
4344template <
class t_TYPE>
4345template <
class t_ANY_TYPE>
4348 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
4349 Optional_Base<t_ANY_TYPE>&& original)
4351 if (original.has_value()) {
4352 this->emplace(std::move(original.value()));
4356template <
class t_TYPE>
4357template <
class t_ANY_TYPE>
4360 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
4361 const std::optional<t_ANY_TYPE>& original)
4362: StdOptionalBase(original)
4366template <
class t_TYPE>
4367template <
class t_ANY_TYPE>
4370 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
4371 std::optional<t_ANY_TYPE>&& original)
4372: StdOptionalBase(
std::move(original))
4376template <
class t_TYPE>
4377template <
class... t_ARGS>
4384template <
class t_TYPE>
4385template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
4389 std::initializer_list<t_INIT_LIST_TYPE> il,
4391: StdOptionalBase(
bsl::
in_place, il,
std::forward<t_ARGS>(args)...)
4395#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
4396template <
class t_TYPE>
4397template <
class t_INVOCABLE,
class t_ARG>
4400 Optional_InvokeConstructorTag ,
4401 t_INVOCABLE&& invocable,
4403: StdOptionalBase(Optional_ImmovableHelper<t_TYPE, t_INVOCABLE, t_ARG>{
4404 std::forward<t_INVOCABLE>(invocable),
4405 std::forward<t_ARG>(arg)})
4410template <
class t_TYPE>
4415 "Should not be called for non-allocator-aware types");
4418template <
class t_TYPE>
4425 "Should not be called for non-allocator-aware types");
4428template <
class t_TYPE>
4429template <
class t_ANY_TYPE>
4434 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
4438 "Should not be called for non-allocator-aware types");
4441template <
class t_TYPE>
4442template <
class t_ANY_TYPE>
4447 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
4448 const Optional_Base<t_ANY_TYPE>&)
4451 "Should not be called for non-allocator-aware types");
4454template <
class t_TYPE>
4455template <
class t_ANY_TYPE>
4460 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
4461 Optional_Base<t_ANY_TYPE>&&)
4464 "Should not be called for non-allocator-aware types");
4467template <
class t_TYPE>
4468template <
class t_ANY_TYPE>
4473 BloombergLP::bslstl::Optional_CopyConstructFromStdOptional,
4474 const std::optional<t_ANY_TYPE>&)
4477 "Should not be called for non-allocator-aware types");
4480template <
class t_TYPE>
4481template <
class t_ANY_TYPE>
4486 BloombergLP::bslstl::Optional_MoveConstructFromStdOptional,
4487 std::optional<t_ANY_TYPE>&&)
4490 "Should not be called for non-allocator-aware types");
4493template <
class t_TYPE>
4494template <
class... t_ARGS>
4502 "Should not be called for non-allocator-aware types");
4505template <
class t_TYPE>
4506template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
4512 std::initializer_list<t_INIT_LIST_TYPE>,
4516 "Should not be called for non-allocator-aware types");
4520template <
class t_TYPE>
4521template <
class t_ANY_TYPE>
4525 StdOptionalBase::operator=(std::forward<t_ANY_TYPE>(rhs));
4528# ifndef BDE_OMIT_INTERNAL_DEPRECATED
4529template <
class t_TYPE>
4540template <
class t_TYPE>
4558template <
class t_TYPE>
4564template <
class t_TYPE>
4570template <
class t_TYPE>
4574 if (original.has_value()) {
4575 emplace(original.value());
4579template <
class t_TYPE>
4582 BloombergLP::bslmf::MovableRef<Optional_Base> original)
4588 if (lvalue.has_value()) {
4589 emplace(MoveUtil::move(*lvalue));
4593template <
class t_TYPE>
4594template <
class t_ANY_TYPE>
4597 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
4603template <
class t_TYPE>
4604template <
class t_ANY_TYPE>
4607 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
4610 if (original.has_value()) {
4611 emplace(original.value());
4615template <
class t_TYPE>
4616template <
class t_ANY_TYPE>
4619 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
4623 if (lvalue.has_value()) {
4624 emplace(MoveUtil::move(*lvalue));
4628#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
4629template <
class t_TYPE>
4630template <
class... t_ARGS>
4639# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4640template <
class t_TYPE>
4641template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
4645 std::initializer_list<t_INIT_LIST_TYPE> il,
4653template <
class t_TYPE>
4658 "Should not be called for non-allocator-aware types");
4661template <
class t_TYPE>
4668 "Should not be called for non-allocator-aware types");
4671template <
class t_TYPE>
4678 "Should not be called for non-allocator-aware types");
4681template <
class t_TYPE>
4686 BloombergLP::bslmf::MovableRef<Optional_Base>)
4689 "Should not be called for non-allocator-aware types");
4692template <
class t_TYPE>
4693template <
class t_ANY_TYPE>
4698 BloombergLP::bslstl::Optional_ConstructFromForwardRef,
4702 "Should not be called for non-allocator-aware types");
4705template <
class t_TYPE>
4706template <
class t_ANY_TYPE>
4711 BloombergLP::bslstl::Optional_CopyConstructFromOtherOptional,
4715 "Should not be called for non-allocator-aware types");
4718template <
class t_TYPE>
4719template <
class t_ANY_TYPE>
4724 BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional,
4728 "Should not be called for non-allocator-aware types");
4731#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
4732template <
class t_TYPE>
4733template <
class... t_ARGS>
4742 "Should not be called for non-allocator-aware types");
4745# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4746template <
class t_TYPE>
4747template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
4753 std::initializer_list<t_INIT_LIST_TYPE>,
4757 "Should not be called for non-allocator-aware types");
4763template <
class t_TYPE>
4764template <
class t_ANY_TYPE>
4775# ifndef BDE_OMIT_INTERNAL_DEPRECATED
4776template <
class t_TYPE>
4782 return d_value.value();
4787template <
class t_TYPE>
4793 return d_value.value();
4799#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
4800template <
class t_TYPE>
4801template <
class... t_ARGS>
4807 return d_value.emplace(NULL,
4811# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4812template <
class t_TYPE>
4813template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
4815 std::initializer_list<t_INIT_LIST_TYPE> il,
4818 return d_value.emplace(
4824template <
class t_TYPE>
4831template <
class t_TYPE>
4835 bsl::is_nothrow_swappable<t_TYPE>::value)
4837 if (this->has_value() && other.has_value()) {
4838 BloombergLP::bslalg::SwapUtil::swap(
4842 else if (this->has_value()) {
4843 other.emplace(MoveUtil::move(d_value.value()));
4846 else if (other.has_value()) {
4847 this->emplace(MoveUtil::move(*other));
4852# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4853template <
class t_TYPE>
4860 return d_value.value();
4862template <
class t_TYPE>
4870 return std::move(d_value.value());
4874template <
class t_TYPE>
4881 return d_value.value();
4886# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4887template <
class t_TYPE>
4888template <
class t_ANY_TYPE>
4894 return t_TYPE(std::move(d_value.value()));
4897 return t_TYPE(std::forward<t_ANY_TYPE>(value));
4902template <
class t_TYPE>
4904Optional_Base<t_TYPE, false>&
4907 if (rhs.has_value()) {
4908 if (this->has_value()) {
4909 d_value.
value() = *rhs;
4921template <
class t_TYPE>
4925 BloombergLP::bslmf::MovableRef<Optional_Base> rhs)
4928 if (lvalue.has_value()) {
4929 if (this->has_value()) {
4930 d_value.value() = MoveUtil::move(*lvalue);
4933 emplace(MoveUtil::move(*lvalue));
4942# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4943template <
class t_TYPE>
4949 return d_value.value();
4952template <
class t_TYPE>
4958 return std::move(d_value.value());
4961template <
class t_TYPE>
4967 return d_value.value();
4971template <
class t_TYPE>
4982template <
class t_TYPE>
4986 return d_value.hasValue();
4989# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
4990template <
class t_TYPE>
4998 return d_value.value();
5001template <
class t_TYPE>
5009 return std::move(d_value.value());
5013template <
class t_TYPE>
5021 return d_value.value();
5026# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
5028template <
class t_TYPE>
5029template <
class t_ANY_TYPE>
5037 return t_TYPE(d_value.value());
5046template <
class t_TYPE>
5047template <
class t_ANY_TYPE>
5055 return t_TYPE(d_value.value());
5065template <
class t_TYPE>
5074# ifdef BSLS_COMPILERFEATURES_SUPPORT_REF_QUALIFIERS
5075template <
class t_TYPE>
5081 return d_value.value();
5084template <
class t_TYPE>
5090 return std::move(d_value.value());
5094template <
class t_TYPE>
5100 return d_value.value();
5104#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
5105template <
class t_TYPE>
5126#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
5128template <
class t_TYPE>
5129template <
class t_INVOCABLE,
class t_ARG>
5132 BloombergLP::bslstl::Optional_InvokeConstructorTag tag,
5133 t_INVOCABLE&& invocable,
5135: BaseType(tag,
std::forward<t_INVOCABLE>(invocable),
std::forward<t_ARG>(arg))
5141template <
class t_TYPE>
5147template <
class t_TYPE>
5154#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5155template <
class t_TYPE>
5156template <
class t_DERIVED>
5158 BloombergLP::bslmf::MovableRef<t_DERIVED> original,
5162: BaseType(MoveUtil::move(static_cast<BaseType&>(original)))
5167template <
class t_TYPE>
5168template <
class t_ANY_TYPE>
5173: BaseType(BloombergLP::
bslstl::Optional_ConstructFromForwardRef(),
5178template <
class t_TYPE>
5179template <
class t_ANY_TYPE>
5184: BaseType(BloombergLP::
bslstl::Optional_ConstructFromForwardRef(),
5189template <
class t_TYPE>
5190template <
class t_ANY_TYPE>
5197: BaseType(BloombergLP::
bslstl::Optional_CopyConstructFromOtherOptional(),
5202template <
class t_TYPE>
5203template <
class t_ANY_TYPE>
5209: BaseType(BloombergLP::
bslstl::Optional_CopyConstructFromOtherOptional(),
5214template <
class t_TYPE>
5215template <
class t_ANY_TYPE>
5220: BaseType(BloombergLP::
bslstl::Optional_MoveConstructFromOtherOptional(),
5222 static_cast<BloombergLP::
bslstl::Optional_Base<t_ANY_TYPE>&>(
5227template <
class t_TYPE>
5228template <
class t_ANY_TYPE>
5233: BaseType(BloombergLP::
bslstl::Optional_MoveConstructFromOtherOptional(),
5235 static_cast<BloombergLP::
bslstl::Optional_Base<t_ANY_TYPE>&>(
5240#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
5241template <
class t_TYPE>
5242template <
class t_ANY_TYPE>
5244 const std::optional<t_ANY_TYPE>& original,
5248: BaseType(BloombergLP::
bslstl::Optional_CopyConstructFromStdOptional(),
5253template <
class t_TYPE>
5254template <
class t_ANY_TYPE>
5256 const std::optional<t_ANY_TYPE>& original,
5260: BaseType(BloombergLP::
bslstl::Optional_CopyConstructFromStdOptional(),
5265template <
class t_TYPE>
5266template <
class t_ANY_TYPE>
5268 std::optional<t_ANY_TYPE>&& original,
5271: BaseType(BloombergLP::
bslstl::Optional_MoveConstructFromStdOptional(),
5272 std::move(original))
5276template <
class t_TYPE>
5277template <
class t_ANY_TYPE>
5279 std::optional<t_ANY_TYPE>&& original,
5282: BaseType(BloombergLP::
bslstl::Optional_MoveConstructFromStdOptional(),
5283 std::move(original))
5288#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
5289template <
class t_TYPE>
5290template <
class... t_ARGS>
5297#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5298template <
class t_TYPE>
5299template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
5302 std::initializer_list<t_INIT_LIST_TYPE> il,
5310template <
class t_TYPE>
5316template <
class t_TYPE>
5324template <
class t_TYPE>
5332template <
class t_TYPE>
5333template <
class t_DERIVED>
5341 MoveUtil::move(static_cast<BaseType&>(original)))
5348template <
class t_TYPE>
5349template <
class t_ANY_TYPE>
5358 BloombergLP::
bslstl::Optional_ConstructFromForwardRef(),
5363template <
class t_TYPE>
5364template <
class t_ANY_TYPE>
5373 BloombergLP::
bslstl::Optional_ConstructFromForwardRef(),
5378template <
class t_TYPE>
5379template <
class t_ANY_TYPE>
5390 BloombergLP::
bslstl::Optional_CopyConstructFromOtherOptional(),
5395template <
class t_TYPE>
5396template <
class t_ANY_TYPE>
5406 BloombergLP::
bslstl::Optional_CopyConstructFromOtherOptional(),
5411template <
class t_TYPE>
5412template <
class t_ANY_TYPE>
5421 BloombergLP::
bslstl::Optional_MoveConstructFromOtherOptional(),
5423 static_cast<BloombergLP::
bslstl::Optional_Base<t_ANY_TYPE>&>(
5428template <
class t_TYPE>
5429template <
class t_ANY_TYPE>
5438 BloombergLP::
bslstl::Optional_MoveConstructFromOtherOptional(),
5440 static_cast<BloombergLP::
bslstl::Optional_Base<t_ANY_TYPE>&>(
5445#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
5446template <
class t_TYPE>
5447template <
class t_ANY_TYPE>
5451 const std::optional<t_ANY_TYPE>& original,
5458 BloombergLP::
bslstl::Optional_CopyConstructFromStdOptional(),
5463template <
class t_TYPE>
5464template <
class t_ANY_TYPE>
5467 AllocType allocator,
5468 const std::optional<t_ANY_TYPE>& original,
5472: BaseType(
bsl::allocator_arg_t(),
5474 BloombergLP::
bslstl::Optional_CopyConstructFromStdOptional(),
5479template <
class t_TYPE>
5480template <
class t_ANY_TYPE>
5483 AllocType allocator,
5484 std::optional<t_ANY_TYPE>&& original,
5487: BaseType(
bsl::allocator_arg_t(),
5489 BloombergLP::
bslstl::Optional_MoveConstructFromStdOptional(),
5490 std::move(original))
5494template <
class t_TYPE>
5495template <
class t_ANY_TYPE>
5498 AllocType allocator,
5499 std::optional<t_ANY_TYPE>&& original,
5502: BaseType(
bsl::allocator_arg_t(),
5504 BloombergLP::
bslstl::Optional_MoveConstructFromStdOptional(),
5505 std::move(original))
5510#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
5511template <
class t_TYPE>
5512template <
class... t_ARGS>
5518: BaseType(
bsl::allocator_arg,
5524#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5525template <
class t_TYPE>
5526template <
class t_INIT_LIST_TYPE,
class... t_ARGS>
5531 std::initializer_list<t_INIT_LIST_TYPE> il,
5533: BaseType(
bsl::allocator_arg,
5544template <
class t_TYPE>
5552#if !defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5553template <
class t_TYPE>
5554template <
class t_DERIVED>
5558 BaseType& lvalue =
rhs;
5559 BaseType::operator=(MoveUtil::move(lvalue));
5564template <
class t_TYPE>
5565template <
class t_ANY_TYPE>
5570 if (
rhs.has_value()) {
5571 this->assignOrEmplace(*
rhs);
5578template <
class t_TYPE>
5579template <
class t_ANY_TYPE>
5584 BloombergLP::bslstl::Optional_Base<t_ANY_TYPE>& lvalue =
rhs;
5585 if (lvalue.has_value()) {
5586 this->assignOrEmplace(MoveUtil::move(*lvalue));
5593#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5594template <
class t_TYPE>
5595template <
class t_ANY_TYPE>
5600 this->assignOrEmplace(std::forward<t_ANY_TYPE>(
rhs));
5604template <
class t_TYPE>
5607 this->assignOrEmplace(
rhs);
5611template <
class t_TYPE>
5615 this->assignOrEmplace(MoveUtil::move(
rhs));
5619template <
class t_TYPE>
5620template <
class t_ANY_TYPE>
5624 this->assignOrEmplace(
rhs);
5628template <
class t_TYPE>
5629template <
class t_ANY_TYPE>
5633 this->assignOrEmplace(MoveUtil::move(
rhs));
5638#ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
5639template <
class t_TYPE>
5640template <
class t_ANY_TYPE>
5645 if (
rhs.has_value()) {
5646 this->assignOrEmplace(*
rhs);
5653template <
class t_TYPE>
5654template <
class t_ANY_TYPE>
5659 if (
rhs.has_value()) {
5660 this->assignOrEmplace(std::move(*
rhs));
5668#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
5669template <
class t_TYPE>
5670template <
class t_FUNC>
5671constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) &
5673 using ResultType = std::remove_cv_t<std::invoke_result_t<t_FUNC, t_TYPE&>>;
5674 static_assert(!std::is_array_v<ResultType>,
5675 "The callable must return an array");
5676 static_assert(!std::is_same_v<ResultType, nullopt_t>,
5677 "The callable must not return nullopt_t");
5678 static_assert(!std::is_same_v<ResultType, in_place_t>,
5679 "The callable must not return in_place_t");
5680 static_assert(std::is_object_v<ResultType>,
5681 "The callable must return an object type");
5683 if (this->has_value()) {
5684 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
5685 return optional<ResultType>{Optional_InvokeConstructorTag{},
5686 std::forward<t_FUNC>(func),
5689 return optional<ResultType>{};
5692template <
class t_TYPE>
5693template <
class t_FUNC>
5694constexpr auto optional<t_TYPE>::transform(t_FUNC&& func)
const &
5697 std::remove_cv_t<std::invoke_result_t<t_FUNC, const t_TYPE&>>;
5698 static_assert(!std::is_array_v<ResultType>,
5699 "The callable must return an array");
5700 static_assert(!std::is_same_v<ResultType, nullopt_t>,
5701 "The callable must not return nullopt_t");
5702 static_assert(!std::is_same_v<ResultType, in_place_t>,
5703 "The callable must not return in_place_t");
5704 static_assert(std::is_object_v<ResultType>,
5705 "The callable must return an object type");
5707 if (this->has_value()) {
5708 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
5709 return optional<ResultType>{Optional_InvokeConstructorTag{},
5710 std::forward<t_FUNC>(func),
5713 return optional<ResultType>{};
5716template <
class t_TYPE>
5717template <
class t_FUNC>
5718constexpr auto optional<t_TYPE>::transform(t_FUNC&& func) &&
5721 std::remove_cv_t<std::invoke_result_t<t_FUNC, t_TYPE&&>>;
5722 static_assert(!std::is_array_v<ResultType>,
5723 "The callable must return an array");
5724 static_assert(!std::is_same_v<ResultType, nullopt_t>,
5725 "The callable must not return nullopt_t");
5726 static_assert(!std::is_same_v<ResultType, in_place_t>,
5727 "The callable must not return in_place_t");
5728 static_assert(std::is_object_v<ResultType>,
5729 "The callable must return an object type");
5731 if (this->has_value()) {
5732 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
5733 return optional<ResultType>{Optional_InvokeConstructorTag{},
5734 std::forward<t_FUNC>(func),
5737 return optional<ResultType>{};
5740template <
class t_TYPE>
5741template <
class t_FUNC>
5742constexpr auto optional<t_TYPE>::transform(t_FUNC&& func)
const &&
5745 std::remove_cv_t<std::invoke_result_t<t_FUNC, const t_TYPE&&>>;
5746 static_assert(!std::is_array_v<ResultType>,
5747 "The callable must return an array");
5748 static_assert(!std::is_same_v<ResultType, nullopt_t>,
5749 "The callable must not return nullopt_t");
5750 static_assert(!std::is_same_v<ResultType, in_place_t>,
5751 "The callable must not return in_place_t");
5752 static_assert(std::is_object_v<ResultType>,
5753 "The callable must return an object type");
5755 if (this->has_value()) {
5756 using BloombergLP::bslstl::Optional_InvokeConstructorTag;
5757 return optional<ResultType>{Optional_InvokeConstructorTag{},
5758 std::forward<t_FUNC>(func),
5761 return optional<ResultType>{};
5764template <
class t_TYPE>
5765template <
class t_FUNC>
5766constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) &
5768 using ResultType = std::remove_cv_t<std::remove_reference_t<
5769 std::invoke_result_t<t_FUNC, t_TYPE&>>>;
5770 using ::BloombergLP::bslstl::Optional_IsBslOptional;
5771 static_assert(Optional_IsBslOptional<ResultType>::value,
5772 "The callable must return bsl::optional");
5774 if (this->has_value()) {
5775 return std::invoke(std::forward<t_FUNC>(func), **
this);
5777 return ResultType{};
5780template <
class t_TYPE>
5781template <
class t_FUNC>
5782constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func)
const &
5784 using ResultType = std::remove_cv_t<std::remove_reference_t<
5785 std::invoke_result_t<t_FUNC, const t_TYPE&>>>;
5786 using ::BloombergLP::bslstl::Optional_IsBslOptional;
5787 static_assert(Optional_IsBslOptional<ResultType>::value,
5788 "The callable must return bsl::optional");
5790 if (this->has_value()) {
5791 return std::invoke(std::forward<t_FUNC>(func), **
this);
5793 return ResultType{};
5796template <
class t_TYPE>
5797template <
class t_FUNC>
5798constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func) &&
5800 using ResultType = std::remove_cv_t<std::remove_reference_t<
5801 std::invoke_result_t<t_FUNC, t_TYPE&&>>>;
5802 using ::BloombergLP::bslstl::Optional_IsBslOptional;
5803 static_assert(Optional_IsBslOptional<ResultType>::value,
5804 "The callable must return bsl::optional");
5806 if (this->has_value()) {
5807 return std::invoke(std::forward<t_FUNC>(func), std::move(**
this));
5809 return ResultType{};
5812template <
class t_TYPE>
5813template <
class t_FUNC>
5814constexpr auto optional<t_TYPE>::and_then(t_FUNC&& func)
const &&
5816 using ResultType = std::remove_cv_t<std::remove_reference_t<
5817 std::invoke_result_t<t_FUNC, const t_TYPE&&>>>;
5818 using ::BloombergLP::bslstl::Optional_IsBslOptional;
5819 static_assert(Optional_IsBslOptional<ResultType>::value,
5820 "The callable must return bsl::optional");
5822 if (this->has_value()) {
5823 return std::invoke(std::forward<t_FUNC>(func), std::move(**
this));
5825 return ResultType{};
5828template <
class t_TYPE>
5829template <
class t_FUNC>
5831enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
5832 std::is_copy_constructible<t_TYPE>>,
5833 optional<t_TYPE>> optional<t_TYPE>::or_else(t_FUNC&& func)
const &
5835 static_assert(std::is_same_v<remove_cvref_t<std::invoke_result_t<t_FUNC>>,
5837 "The callable must return bsl::optional<T>");
5839 if (this->has_value()) {
5842 return std::forward<t_FUNC>(func)();
5845template <
class t_TYPE>
5846template <
class t_FUNC>
5848enable_if_t<conjunction_v<std::is_invocable<t_FUNC>,
5849 std::is_move_constructible<t_TYPE>>,
5850 optional<t_TYPE>> optional<t_TYPE>::or_else(t_FUNC&& func) &&
5852 static_assert(std::is_same_v<remove_cvref_t<std::invoke_result_t<t_FUNC>>,
5854 "The callable must return bsl::optional<T>");
5856 if (this->has_value()) {
5857 return std::move(*
this);
5859 return std::forward<t_FUNC>(func)();
5867template <
class t_TYPE>
5873 if (
lhs.get_allocator() ==
rhs.get_allocator()) {
5880 bsl::allocator_arg,
lhs.get_allocator(),
rhs);
5882 bsl::allocator_arg,
rhs.get_allocator(),
lhs);
5884 futureLhs.swap(
lhs);
5885 futureRhs.swap(
rhs);
5888template <
class t_TYPE>
5898template <
class t_HASHALG,
class t_TYPE>
5901 using ::BloombergLP::bslh::hashAppend;
5903 if (input.has_value()) {
5914template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5919 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5922 if (
lhs.has_value() &&
rhs.has_value()) {
5925 return lhs.has_value() ==
rhs.has_value();
5928template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5933 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5936 if (
lhs.has_value() &&
rhs.has_value()) {
5940 return lhs.has_value() !=
rhs.has_value();
5943template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5948 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5951 if (!
rhs.has_value()) {
5958template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5963 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5966 if (!
lhs.has_value()) {
5973template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5978 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5981 if (!
lhs.has_value()) {
5988template <
class t_LHS_TYPE,
class t_RHS_TYPE>
5993 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
5996 if (!
rhs.has_value()) {
6004template <
class t_TYPE>
6010 return !value.has_value();
6013#if !(defined(BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON) && \
6014 defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS))
6015template <
class t_TYPE>
6021 return !value.has_value();
6024template <
class t_TYPE>
6030 return value.has_value();
6033template <
class t_TYPE>
6039 return value.has_value();
6042template <
class t_TYPE>
6051template <
class t_TYPE>
6057 return value.has_value();
6060template <
class t_TYPE>
6066 return value.has_value();
6069template <
class t_TYPE>
6078template <
class t_TYPE>
6084 return !value.has_value();
6087template <
class t_TYPE>
6096template <
class t_TYPE>
6105template <
class t_TYPE>
6111 return !value.has_value();
6118template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6122 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6124 { *
lhs ==
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6130template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6134 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6136 {
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6142template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6146 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6148 { *
lhs !=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6154template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6158 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6160 {
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6166template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6170 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6172 { *
lhs <
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6178template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6182 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6184 {
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6190template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6194 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6196 { *
lhs >
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6202template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6206 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6208 {
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6214template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6218 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6220 { *
lhs <=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6226template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6230 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6232 {
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6238template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6242 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS_TYPE>
6244 { *
lhs >=
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6250template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6254 !BloombergLP::bslstl::Optional_DerivedFromOptional<t_LHS_TYPE>
6256 {
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6262#if defined BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON \
6263 && defined BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS
6264template <
class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
6266compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6270 const bool lhs_has_value =
lhs.has_value(),
6271 rhs_has_value =
rhs.has_value();
6272 if (lhs_has_value && rhs_has_value) {
6273 return *lhs <=> *
rhs;
6275 return lhs_has_value <=> rhs_has_value;
6278template <
class t_LHS,
class t_RHS>
6279requires (!BloombergLP::bslstl::Optional_DerivedFromOptional<t_RHS>) &&
6280 three_way_comparable_with<t_LHS, t_RHS>
6282compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6287 return *lhs <=>
rhs;
6289 return strong_ordering::less;
6292template <
class t_TYPE>
6297 return value.has_value() <=>
false;
6300template <
class t_LHS, three_way_comparable_with<t_LHS> t_RHS>
6302compare_three_way_result_t<t_LHS, t_RHS> operator<=>(
6304 const std::optional<t_RHS>&
rhs)
6306 const bool lhs_has_value =
lhs.has_value(),
6307 rhs_has_value =
rhs.has_value();
6308 if (lhs_has_value && rhs_has_value) {
6309 return *lhs <=> *
rhs;
6311 return lhs_has_value <=> rhs_has_value;
6316# ifdef BSLSTL_OPTIONAL_USES_STD_ALIASES
6317template <
class t_TYPE>
6326template <
class t_TYPE>
6337template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6340 const std::optional<t_RHS_TYPE>&
rhs)
6342 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6345 if (
lhs.has_value() &&
rhs.has_value()) {
6348 return lhs.has_value() ==
rhs.has_value();
6351template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6356 { *
lhs == *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6359 if (
lhs.has_value() &&
rhs.has_value()) {
6362 return lhs.has_value() ==
rhs.has_value();
6365template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6368 const std::optional<t_RHS_TYPE>&
rhs)
6370 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6373 if (
lhs.has_value() &&
rhs.has_value()) {
6377 return lhs.has_value() !=
rhs.has_value();
6380template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6385 { *
lhs != *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6388 if (
lhs.has_value() &&
rhs.has_value()) {
6392 return lhs.has_value() !=
rhs.has_value();
6395template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6398 const std::optional<t_RHS_TYPE>&
rhs)
6400 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6403 if (!
rhs.has_value()) {
6410template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6415 { *
lhs < *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6418 if (!
rhs.has_value()) {
6425template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6428 const std::optional<t_RHS_TYPE>&
rhs)
6430 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6433 if (!
lhs.has_value()) {
6440template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6445 { *
lhs > *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6448 if (!
lhs.has_value()) {
6455template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6458 const std::optional<t_RHS_TYPE>&
rhs)
6460 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6463 if (!
lhs.has_value()) {
6470template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6475 { *
lhs <= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6478 if (!
lhs.has_value()) {
6485template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6488 const std::optional<t_RHS_TYPE>&
rhs)
6490 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6493 if (!
rhs.has_value()) {
6499template <
class t_LHS_TYPE,
class t_RHS_TYPE>
6504 { *
lhs >= *
rhs } -> BloombergLP::bslstl::Optional_ConvertibleToBool;
6507 if (!
rhs.has_value()) {
6514template <
class t_TYPE>
6528#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6529template <
class t_TYPE,
class... t_ARGS>
6543#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6544# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6545template <
class t_TYPE,
class t_INIT_LIST_TYPE,
class... t_ARGS>
6549 std::initializer_list<t_INIT_LIST_TYPE> il,
6562template <
class t_TYPE>
6570template <
class t_TYPE>
6576#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
6577template <
class t_TYPE,
class t_ARG,
class... t_ARGS>
6588# if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6589template <
class t_TYPE,
class t_INIT_LIST_TYPE,
class... t_ARGS>
6628# if BSLS_COMPILERFEATURES_CPLUSPLUS >= 202002L && \
6629 defined(BSLS_LIBRARYFEATURES_STDCPP_GNU) && \
6630 (11 <= _GLIBCXX_RELEASE && _GLIBCXX_RELEASE <= 14)
6632#define BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_GNU_WORKAROUND_NEEDED
6635template<
typename _Tp>
6636inline constexpr bool __is_optional_v<bsl::optional<_Tp>> =
true;
6641# if BSLS_COMPILERFEATURES_CPLUSPLUS == 202002L && \
6642 defined(BSLS_PLATFORM_CMP_MSVC) && \
6643 (BSLS_PLATFORM_CMP_VERSION >= 1930 && BSLS_PLATFORM_CMP_VERSION < 1936)
6646#define BSLSTL_OPTIONAL_CPP20_IS_OPTIONAL_MSVC_WORKAROUND_NEEDED
6649template <
typename _Tp>
6650inline constexpr bool _Is_specialization_v<bsl::optional<_Tp>, std::optional> =
6656#undef BSLSTL_OPTIONAL_CONSTEXPR17
6657#undef BSLSTL_OPTIONAL_CONSTEXPR20
6658#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL
6659#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL
6660#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_STD_OPTIONAL
6661#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM_STD_OPTIONAL
6662#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR
6663#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR
6664#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR
6665#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR
6666#undef BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM
6667#undef BSLSTL_OPTIONAL_DEFINE_IF_CONSTRUCTS_FROM
6668#undef BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL
6669#undef BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT
6670#undef BSLSTL_OPTIONAL_DEFINE_IF_EXPLICIT_CONSTRUCT
6671#undef BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT
6672#undef BSLSTL_OPTIONAL_DEFINE_IF_NOT_EXPLICIT_CONSTRUCT
6673#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL
6674#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_STD_OPTIONAL
6675#undef BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED
6676#undef BSLSTL_OPTIONAL_ENABLE_IF_NOT_ALLOCATOR_TAG
6677#undef BSLSTL_OPTIONAL_DEFAULT_TEMPLATE_ARG
6678#undef BSLSTL_OPTIONAL_REQUIRES
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
Definition bslma_bslallocator.h:588
BloombergLP::bslma::Allocator * mechanism() const
Definition bslma_bslallocator.h:1146
decay_imp< U, k_ISARRAY, k_ISFUNC >::type type
Definition bslmf_decay.h:167
Definition bslstl_optional.h:2043
BSLMF_NESTED_TRAIT_DECLARATION_IF(optional, BloombergLP::bslmf::UsesAllocatorArgT, BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value)
BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_ANY_TYPE(t_TYPE, t_ANY_TYPE) &operator
optional(BloombergLP::bslmf::MovableRef< t_DERIVED > original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(t_DERIVED)) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl BSLSTL_OPTIONAL_CONSTEXPR17 optional(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
BSLSTL_OPTIONAL_CONSTEXPR20 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE) &operator
optional(bsl::allocator_arg_t, AllocType allocator)
Definition bslstl_optional.h:5311
BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_DERIVED(t_TYPE, t_DERIVED) &operator
optional(bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(t_DERIVED) original, BSLSTL_OPTIONAL_DECLARE_IF_DERIVED_FROM_OPTIONAL(typename bsl::remove_reference< t_DERIVED >::type))
BSLMF_NESTED_TRAIT_DECLARATION_IF(optional, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value)
BSLSTL_OPTIONAL_CONSTEXPR20 BSLSTL_OPTIONAL_ENABLE_ASSIGN_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &) &operator
BSLSTL_OPTIONAL_CONSTEXPR20 optional(BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
optional(bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
BSLSTL_OPTIONAL_CONSTEXPR17 optional(bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
Definition bslstl_optional.h:5292
optional(bsl::allocator_arg_t, AllocType allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
optional & operator=(const t_TYPE &rhs)
Definition bslstl_optional.h:5605
optional(bsl::allocator_arg_t, AllocType allocator, const optional &original)
Definition bslstl_optional.h:5325
optional(bsl::allocator_arg_t, AllocType allocator, bsl::nullopt_t)
Definition bslstl_optional.h:5317
BSLSTL_OPTIONAL_CONSTEXPR20 optional & operator=(bsl::nullopt_t) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:5546
BSLSTL_OPTIONAL_CONSTEXPR17 optional(BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
optional & operator=(BloombergLP::bslmf::MovableRef< t_TYPE > rhs)
Definition bslstl_optional.h:5613
optional(bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
BSLMF_NESTED_TRAIT_DECLARATION_IF(optional, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< t_TYPE >::value)
optional(bsl::allocator_arg_t, AllocType allocator, bsl::in_place_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARGS)... args)
Definition bslstl_optional.h:5513
optional(bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
BSLSTL_OPTIONAL_CONSTEXPR20 optional(BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
BSLMF_NESTED_TRAIT_DECLARATION_IF(optional, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value)
BSLSTL_OPTIONAL_CONSTEXPR20 optional(const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
BSLSTL_OPTIONAL_CONSTEXPR20 optional(const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
optional(bsl::allocator_arg_t, AllocType allocator, const optional< t_ANY_TYPE > &original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, const t_ANY_TYPE &), BSLSTL_OPTIONAL_DECLARE_IF_EXPLICIT_CONSTRUCT(t_TYPE, const t_ANY_TYPE &))
BSLSTL_OPTIONAL_CONSTEXPR17 optional() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:5142
optional(bsl::allocator_arg_t, AllocType allocator, BSLMF_MOVABLEREF_DEDUCE(optional< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCTS_FROM_BSL_OPTIONAL(t_TYPE, t_ANY_TYPE), BSLSTL_OPTIONAL_DECLARE_IF_NOT_EXPLICIT_CONSTRUCT(t_TYPE, t_ANY_TYPE))
Definition bslma_allocator.h:545
BSLMF_NESTED_TRAIT_DECLARATION_IF(Optional_Base, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Optional_Base, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value)
Optional_Base(BloombergLP::bslmf::MovableRef< Optional_Base > original) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
t_TYPE value_type
Definition bslstl_optional.h:1848
Definition bslstl_optional.h:929
Optional_Base()
Definition bslstl_optional.h:3573
const t_TYPE & value() const
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
BSLMF_NESTED_TRAIT_DECLARATION(Optional_Base, BloombergLP::bslmf::UsesAllocatorArgT)
t_TYPE & operator*()
Definition bslstl_optional.h:4115
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:3943
BSLMF_NESTED_TRAIT_DECLARATION_IF(Optional_Base, BloombergLP::bslmf::IsBitwiseCopyable, BloombergLP::bslmf::IsBitwiseCopyable< t_TYPE >::value)
BSLMF_NESTED_TRAIT_DECLARATION_IF(Optional_Base, BloombergLP::bslmf::IsBitwiseMoveable, BloombergLP::bslmf::IsBitwiseMoveable< t_TYPE >::value)
BSLMF_NESTED_TRAIT_DECLARATION(Optional_Base, BloombergLP::bslma::UsesBslmaAllocator)
Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_DOES_NOT_PROPAGATE_ALLOCATOR(t_TYPE, t_ANY_TYPE))
Optional_Base(BloombergLP::bslmf::MovableRef< Optional_Base > original) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl Optional_Base(BloombergLP::bslstl::Optional_ConstructFromForwardRef, BSLS_COMPILERFEATURES_FORWARD_REF(t_ANY_TYPE) value)
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
Optional_Base(BloombergLP::bslstl::Optional_MoveConstructFromOtherOptional, BSLMF_MOVABLEREF_DEDUCE(Optional_Base< t_ANY_TYPE >) original, BSLSTL_OPTIONAL_DECLARE_IF_CONSTRUCT_PROPAGATES_ALLOCATOR(t_TYPE, t_ANY_TYPE))
#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_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#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)
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
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 bslmf_issame.h:146
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 bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisecopyable.h:298
Definition bslstl_optional.h:707
Definition bslstl_optional.h:673
Definition bslstl_optional.h:708
Definition bslstl_optional.h:710
Definition bslstl_optional.h:738
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
BSLMF_NESTED_TRAIT_DECLARATION_IF(Optional_Data, bslmf::IsBitwiseCopyable, bslmf::IsBitwiseCopyable< t_TYPE >::value)
Definition bslstl_optional.h:842
~Optional_Data()
Destroy the managed value_type object, if it exists.
Definition bslstl_optional.h:3557
Definition bslstl_optional.h:567
Definition bslstl_optional.h:601
Definition bslstl_optional.h:709
Definition bslstl_optional.h:711
Definition bslstl_optional.h:499
Definition bslstl_optional.h:619
BSLS_KEYWORD_CONSTEXPR Optional_OptNoSuchType(int) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_optional.h:632
Definition bslstl_optional.h:654
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335
TYPE & object()
Definition bsls_objectbuffer.h:352