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 optional(const optional &);
91 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 optional &operator=(const optional &); // constexpr in C++20
108 optional &operator=(optional &&) noexcept(see below); // constexpr in C++20
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>;
249 "instantiation of optional with a non-object type is undefined behavior");
298 "instantiation of optional with a non-object type is undefined behavior");
408 // optional<T&> is currently required to be ill-formed. However, it may
638 class optional;
641 template <class _Tp> struct __is_std_optional<optional<_Tp>> : true_type {};
644 class optional
656 "instantiation of optional with in_place_t is ill-formed");
658 "instantiation of optional with nullopt_t is ill-formed");
660 "instantiation of optional with a reference type is ill-formed");
662 "instantiation of optional with a non-destructible type is ill-formed");
664 "instantiation of optional with an array type is ill-formed");
683 _IsNotSame<__uncvref_t<_Up>, optional>::value,
689 template <class _Up, class _Opt = optional<_Up>>
700 template <class _Up, class _Opt = optional<_Up>>
748 _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
749 _LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
750 _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
751 _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
761 constexpr explicit optional(_InPlaceT, _Args&&... __args)
768 constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
775 constexpr optional(_Up&& __v)
782 constexpr explicit optional(_Up&& __v)
785 // LWG2756: conditionally explicit conversion from const optional<_Up>&
790 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)
798 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(const optional<_Up>& __v)
803 // LWG2756: conditionally explicit conversion from optional<_Up>&&
808 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)
816 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)
824 constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
830 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept
836 _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;
837 _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&&) = default;
843 _IsNotSame<__uncvref_t<_Up>, optional>,
853 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
868 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
869 operator=(const optional<_Up>& __v)
880 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
881 operator=(optional<_Up>&& __v)
918 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)
948 _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
957 _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
966 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
975 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
984 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
993 _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
1044 "optional<T>::value_or: T must be copy constructible");
1046 "optional<T>::value_or: U must be convertible to T");
1056 "optional<T>::value_or: T must be move constructible");
1058 "optional<T>::value_or: U must be convertible to T");
1069 "Result of f(value()) must be a specialization of std::optional");
1080 "Result of f(value()) must be a specialization of std::optional");
1091 "Result of f(std::move(value())) must be a specialization of std::optional");
1102 "Result of f(std::move(value())) must be a specialization of std::optional");
1119 … return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
1120 return optional<_Up>();
1134 … return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value());
1135 return optional<_Up>();
1149 …return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::mo…
1150 return optional<_Up>();
1164 …return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::mo…
1165 return optional<_Up>();
1170 constexpr optional or_else(_Func&& __f) const& requires is_copy_constructible_v<value_type> {
1171 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
1172 "Result of f() should be the same type as this optional");
1180 constexpr optional or_else(_Func&& __f) && requires is_move_constructible_v<value_type> {
1181 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
1182 "Result of f() should be the same type as this optional");
1194 optional(_Tp) -> optional<_Tp>;
1205 operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
1221 operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
1237 operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
1253 operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
1269 operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
1285 operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
1298 operator==(const optional<_Tp>& __x, nullopt_t) noexcept
1306 operator==(nullopt_t, const optional<_Tp>& __x) noexcept
1314 operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
1322 operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
1330 operator<(const optional<_Tp>&, nullopt_t) noexcept
1338 operator<(nullopt_t, const optional<_Tp>& __x) noexcept
1346 operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
1354 operator<=(nullopt_t, const optional<_Tp>&) noexcept
1362 operator>(const optional<_Tp>& __x, nullopt_t) noexcept
1370 operator>(nullopt_t, const optional<_Tp>&) noexcept
1378 operator>=(const optional<_Tp>&, nullopt_t) noexcept
1386 operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
1399 operator==(const optional<_Tp>& __x, const _Up& __v)
1411 operator==(const _Tp& __v, const optional<_Up>& __x)
1423 operator!=(const optional<_Tp>& __x, const _Up& __v)
1435 operator!=(const _Tp& __v, const optional<_Up>& __x)
1447 operator<(const optional<_Tp>& __x, const _Up& __v)
1459 operator<(const _Tp& __v, const optional<_Up>& __x)
1471 operator<=(const optional<_Tp>& __x, const _Up& __v)
1483 operator<=(const _Tp& __v, const optional<_Up>& __x)
1495 operator>(const optional<_Tp>& __x, const _Up& __v)
1507 operator>(const _Tp& __v, const optional<_Up>& __x)
1519 operator>=(const optional<_Tp>& __x, const _Up& __v)
1531 operator>=(const _Tp& __v, const optional<_Up>& __x)
1543 swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
1550 optional<decay_t<_Tp>> make_optional(_Tp&& __v)
1552 return optional<decay_t<_Tp>>(_VSTD::forward<_Tp>(__v));
1557 optional<_Tp> make_optional(_Args&&... __args)
1559 return optional<_Tp>(in_place, _VSTD::forward<_Args>(__args)...);
1564 optional<_Tp> make_optional(initializer_list<_Up> __il, _Args&&... __args)
1566 return optional<_Tp>(in_place, __il, _VSTD::forward<_Args>(__args)...);
1571 __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>>
1575 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;
1580 size_t operator()(const optional<_Tp>& __opt) const