From Jason Turner

[optional.observe]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp954b21xw/{from.md → to.md} +101 -0
tmp/tmp954b21xw/{from.md → to.md} RENAMED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Observers <a id="optional.observe">[[optional.observe]]</a>
2
+
3
+ ``` cpp
4
+ constexpr const T* operator->() const;
5
+ constexpr T* operator->();
6
+ ```
7
+
8
+ *Requires:* `*this` contains a value.
9
+
10
+ *Returns:* `val`.
11
+
12
+ *Throws:* Nothing.
13
+
14
+ *Remarks:* These functions shall be constexpr functions.
15
+
16
+ ``` cpp
17
+ constexpr const T& operator*() const&;
18
+ constexpr T& operator*() &;
19
+ ```
20
+
21
+ *Requires:* `*this` contains a value.
22
+
23
+ *Returns:* `*val`.
24
+
25
+ *Throws:* Nothing.
26
+
27
+ *Remarks:* These functions shall be constexpr functions.
28
+
29
+ ``` cpp
30
+ constexpr T&& operator*() &&;
31
+ constexpr const T&& operator*() const&&;
32
+ ```
33
+
34
+ *Requires:* `*this` contains a value.
35
+
36
+ *Effects:* Equivalent to: `return std::move(*val);`
37
+
38
+ ``` cpp
39
+ constexpr explicit operator bool() const noexcept;
40
+ ```
41
+
42
+ *Returns:* `true` if and only if `*this` contains a value.
43
+
44
+ *Remarks:* This function shall be a constexpr function.
45
+
46
+ ``` cpp
47
+ constexpr bool has_value() const noexcept;
48
+ ```
49
+
50
+ *Returns:* `true` if and only if `*this` contains a value.
51
+
52
+ *Remarks:* This function shall be a constexpr function.
53
+
54
+ ``` cpp
55
+ constexpr const T& value() const&;
56
+ constexpr T& value() &;
57
+ ```
58
+
59
+ *Effects:* Equivalent to:
60
+
61
+ ``` cpp
62
+ return bool(*this) ? *val : throw bad_optional_access();
63
+ ```
64
+
65
+ ``` cpp
66
+ constexpr T&& value() &&;
67
+ constexpr const T&& value() const&&;
68
+ ```
69
+
70
+ *Effects:* Equivalent to:
71
+
72
+ ``` cpp
73
+ return bool(*this) ? std::move(*val) : throw bad_optional_access();
74
+ ```
75
+
76
+ ``` cpp
77
+ template <class U> constexpr T value_or(U&& v) const&;
78
+ ```
79
+
80
+ *Effects:* Equivalent to:
81
+
82
+ ``` cpp
83
+ return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
84
+ ```
85
+
86
+ *Remarks:* If `is_copy_constructible_v<T> && is_convertible_v<U&&, T>`
87
+ is `false`, the program is ill-formed.
88
+
89
+ ``` cpp
90
+ template <class U> constexpr T value_or(U&& v) &&;
91
+ ```
92
+
93
+ *Effects:* Equivalent to:
94
+
95
+ ``` cpp
96
+ return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
97
+ ```
98
+
99
+ *Remarks:* If `is_move_constructible_v<T> && is_convertible_v<U&&, T>`
100
+ is `false`, the program is ill-formed.
101
+