Lines Matching refs:optional

14     optional synopsis
19 // 23.6.3, optional for object types
20 template <class T> class optional;
31 constexpr bool operator==(const optional<T>&, const optional<U>&);
33 constexpr bool operator!=(const optional<T>&, const optional<U>&);
35 constexpr bool operator<(const optional<T>&, const optional<U>&);
37 constexpr bool operator>(const optional<T>&, const optional<U>&);
39 constexpr bool operator<=(const optional<T>&, const optional<U>&);
41 constexpr bool operator>=(const optional<T>&, const optional<U>&);
44 template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
45 template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
46 template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
47 template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
48 template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
49 template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
50 template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
51 template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
52 template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
53 template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
54 template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
55 template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
58 template <class T, class U> constexpr bool operator==(const optional<T>&, const U&);
59 template <class T, class U> constexpr bool operator==(const T&, const optional<U>&);
60 template <class T, class U> constexpr bool operator!=(const optional<T>&, const U&);
61 template <class T, class U> constexpr bool operator!=(const T&, const optional<U>&);
62 template <class T, class U> constexpr bool operator<(const optional<T>&, const U&);
63 template <class T, class U> constexpr bool operator<(const T&, const optional<U>&);
64 template <class T, class U> constexpr bool operator<=(const optional<T>&, const U&);
65 template <class T, class U> constexpr bool operator<=(const T&, const optional<U>&);
66 template <class T, class U> constexpr bool operator>(const optional<T>&, const U&);
67 template <class T, class U> constexpr bool operator>(const T&, const optional<U>&);
68 template <class T, class U> constexpr bool operator>=(const optional<T>&, const U&);
69 template <class T, class U> constexpr bool operator>=(const T&, const optional<U>&);
72 …template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below ); // constexpr in C++…
73 template <class T> constexpr optional<see below > make_optional(T&&);
75 constexpr optional<T> make_optional(Args&&... args);
77 constexpr optional<T> make_optional(initializer_list<U> il, Args&&... args);
81 template <class T> struct hash<optional<T>>;
83 template <class T> class optional {
88 constexpr optional() noexcept;
89 constexpr optional(nullopt_t) noexcept;
90 constexpr optional(const optional &);
91 constexpr optional(optional &&) noexcept(see below);
92 template <class... Args> constexpr explicit optional(in_place_t, Args &&...);
94 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
96 constexpr explicit(see-below) optional(U &&);
98 explicit(see-below) optional(const optional<U> &); // constexpr in C++20
100 explicit(see-below) optional(optional<U> &&); // constexpr in C++20
103 ~optional(); // constexpr in C++20
106 optional &operator=(nullopt_t) noexcept; // constexpr in C++20
107 constexpr optional &operator=(const optional &);
108 constexpr optional &operator=(optional &&) noexcept(see below);
109 template <class U = T> optional &operator=(U &&); // constexpr in C++20
110 template <class U> optional &operator=(const optional<U> &); // constexpr in C++20
111 template <class U> optional &operator=(optional<U> &&); // constexpr in C++20
117 void swap(optional &) noexcept(see below ); // constexpr in C++20
135 // [optional.monadic], monadic operations
144 template<class F> constexpr optional or_else(F&& f) &&; // since C++23
145 template<class F> constexpr optional or_else(F&& f) const&; // since C++23
155 optional(T) -> optional<T>;
182 // [optional.syn]
236 "instantiation of optional with a non-object type is undefined behavior");
285 "instantiation of optional with a non-object type is undefined behavior");
395 // optional<T&> is currently required to be ill-formed. However, it may
625 class optional;
628 template <class _Tp> struct __is_std_optional<optional<_Tp>> : true_type {};
631 class optional
643 "instantiation of optional with in_place_t is ill-formed");
645 "instantiation of optional with nullopt_t is ill-formed");
647 "instantiation of optional with a reference type is ill-formed");
649 "instantiation of optional with a non-destructible type is ill-formed");
651 "instantiation of optional with an array type is ill-formed");
670 _IsNotSame<__remove_cvref_t<_Up>, optional>::value,
676 template <class _Up, class _Opt = optional<_Up>>
687 template <class _Up, class _Opt = optional<_Up>>
735 _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
736 _LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
737 _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
738 _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
748 constexpr explicit optional(_InPlaceT, _Args&&... __args)
755 constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
762 constexpr optional(_Up&& __v)
769 constexpr explicit optional(_Up&& __v)
772 // LWG2756: conditionally explicit conversion from const optional<_Up>&
777 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
785 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v)
790 // LWG2756: conditionally explicit conversion from optional<_Up>&&
795 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v)
803 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v)
811 constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
817 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept
823 constexpr optional& operator=(const optional&) = default;
824 constexpr optional& operator=(optional&&) = default;
830 _IsNotSame<__remove_cvref_t<_Up>, optional>,
840 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
855 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
856 operator=(const optional<_Up>& __v)
867 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
868 operator=(optional<_Up>&& __v)
905 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt)
935 _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
944 _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
953 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
962 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
971 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
980 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
1031 "optional<T>::value_or: T must be copy constructible");
1033 "optional<T>::value_or: U must be convertible to T");
1043 "optional<T>::value_or: T must be move constructible");
1045 "optional<T>::value_or: U must be convertible to T");
1056 "Result of f(value()) must be a specialization of std::optional");
1067 "Result of f(value()) must be a specialization of std::optional");
1078 "Result of f(std::move(value())) must be a specialization of std::optional");
1089 "Result of f(std::move(value())) must be a specialization of std::optional");
1106 … return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
1107 return optional<_Up>();
1121 … return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
1122 return optional<_Up>();
1136 …return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::mo…
1137 return optional<_Up>();
1151 …return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::mo…
1152 return optional<_Up>();
1157 constexpr optional or_else(_Func&& __f) const& requires is_copy_constructible_v<value_type> {
1158 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
1159 "Result of f() should be the same type as this optional");
1167 constexpr optional or_else(_Func&& __f) && requires is_move_constructible_v<value_type> {
1168 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
1169 "Result of f() should be the same type as this optional");
1181 optional(_Tp) -> optional<_Tp>;
1192 operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
1208 operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
1224 operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
1240 operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
1256 operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
1272 operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
1285 operator==(const optional<_Tp>& __x, nullopt_t) noexcept
1293 operator==(nullopt_t, const optional<_Tp>& __x) noexcept
1301 operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
1309 operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
1317 operator<(const optional<_Tp>&, nullopt_t) noexcept
1325 operator<(nullopt_t, const optional<_Tp>& __x) noexcept
1333 operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
1341 operator<=(nullopt_t, const optional<_Tp>&) noexcept
1349 operator>(const optional<_Tp>& __x, nullopt_t) noexcept
1357 operator>(nullopt_t, const optional<_Tp>&) noexcept
1365 operator>=(const optional<_Tp>&, nullopt_t) noexcept
1373 operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
1386 operator==(const optional<_Tp>& __x, const _Up& __v)
1398 operator==(const _Tp& __v, const optional<_Up>& __x)
1410 operator!=(const optional<_Tp>& __x, const _Up& __v)
1422 operator!=(const _Tp& __v, const optional<_Up>& __x)
1434 operator<(const optional<_Tp>& __x, const _Up& __v)
1446 operator<(const _Tp& __v, const optional<_Up>& __x)
1458 operator<=(const optional<_Tp>& __x, const _Up& __v)
1470 operator<=(const _Tp& __v, const optional<_Up>& __x)
1482 operator>(const optional<_Tp>& __x, const _Up& __v)
1494 operator>(const _Tp& __v, const optional<_Up>& __x)
1506 operator>=(const optional<_Tp>& __x, const _Up& __v)
1518 operator>=(const _Tp& __v, const optional<_Up>& __x)
1530 swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
1537 optional<decay_t<_Tp>> make_optional(_Tp&& __v)
1539 return optional<decay_t<_Tp>>(_VSTD::forward<_Tp>(__v));
1544 optional<_Tp> make_optional(_Args&&... __args)
1546 return optional<_Tp>(in_place, _VSTD::forward<_Args>(__args)...);
1551 optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args)
1553 return optional<_Tp>(in_place, __il, _VSTD::forward<_Args>(__args)...);
1558 __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>>
1562 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;
1567 size_t operator()(const optional<_Tp>& __opt) const