From Jason Turner

[optional.observe]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcv0r_t4u/{from.md → to.md} +10 -14
tmp/tmpcv0r_t4u/{from.md → to.md} RENAMED
@@ -1,36 +1,32 @@
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
  *Preconditions:* `*this` contains a value.
9
 
10
  *Returns:* `val`.
11
 
12
- *Throws:* Nothing.
13
-
14
  *Remarks:* These functions are constexpr functions.
15
 
16
  ``` cpp
17
- constexpr const T& operator*() const&;
18
- constexpr T& operator*() &;
19
  ```
20
 
21
  *Preconditions:* `*this` contains a value.
22
 
23
  *Returns:* `*val`.
24
 
25
- *Throws:* Nothing.
26
-
27
  *Remarks:* These functions are constexpr functions.
28
 
29
  ``` cpp
30
- constexpr T&& operator*() &&;
31
- constexpr const T&& operator*() const&&;
32
  ```
33
 
34
  *Preconditions:* `*this` contains a value.
35
 
36
  *Effects:* Equivalent to: `return std::move(*val);`
@@ -57,22 +53,22 @@ 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
  ```
@@ -81,11 +77,11 @@ template<class U> constexpr T value_or(U&& v) const&;
81
  `true`.
82
 
83
  *Effects:* Equivalent to:
84
 
85
  ``` cpp
86
- return bool(*this) ? **this : static_cast<T>(std::forward<U>(v));
87
  ```
88
 
89
  ``` cpp
90
  template<class U> constexpr T value_or(U&& v) &&;
91
  ```
@@ -94,8 +90,8 @@ template<class U> constexpr T value_or(U&& v) &&;
94
  `true`.
95
 
96
  *Effects:* Equivalent to:
97
 
98
  ``` cpp
99
- return bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v));
100
  ```
101
 
 
1
  #### Observers <a id="optional.observe">[[optional.observe]]</a>
2
 
3
  ``` cpp
4
+ constexpr const T* operator->() const noexcept;
5
+ constexpr T* operator->() noexcept;
6
  ```
7
 
8
  *Preconditions:* `*this` contains a value.
9
 
10
  *Returns:* `val`.
11
 
 
 
12
  *Remarks:* These functions are constexpr functions.
13
 
14
  ``` cpp
15
+ constexpr const T& operator*() const & noexcept;
16
+ constexpr T& operator*() & noexcept;
17
  ```
18
 
19
  *Preconditions:* `*this` contains a value.
20
 
21
  *Returns:* `*val`.
22
 
 
 
23
  *Remarks:* These functions are constexpr functions.
24
 
25
  ``` cpp
26
+ constexpr T&& operator*() && noexcept;
27
+ constexpr const T&& operator*() const && noexcept;
28
  ```
29
 
30
  *Preconditions:* `*this` contains a value.
31
 
32
  *Effects:* Equivalent to: `return std::move(*val);`
 
53
  ```
54
 
55
  *Effects:* Equivalent to:
56
 
57
  ``` cpp
58
+ return has_value() ? *val : throw bad_optional_access();
59
  ```
60
 
61
  ``` cpp
62
  constexpr T&& value() &&;
63
  constexpr const T&& value() const &&;
64
  ```
65
 
66
  *Effects:* Equivalent to:
67
 
68
  ``` cpp
69
+ return has_value() ? std::move(*val) : throw bad_optional_access();
70
  ```
71
 
72
  ``` cpp
73
  template<class U> constexpr T value_or(U&& v) const &;
74
  ```
 
77
  `true`.
78
 
79
  *Effects:* Equivalent to:
80
 
81
  ``` cpp
82
+ return has_value() ? **this : static_cast<T>(std::forward<U>(v));
83
  ```
84
 
85
  ``` cpp
86
  template<class U> constexpr T value_or(U&& v) &&;
87
  ```
 
90
  `true`.
91
 
92
  *Effects:* Equivalent to:
93
 
94
  ``` cpp
95
+ return has_value() ? std::move(**this) : static_cast<T>(std::forward<U>(v));
96
  ```
97