tmp/tmp7s372qwg/{from.md → to.md}
RENAMED
|
@@ -18,13 +18,13 @@ move-assignment operator, the copy-assignment operator, or `valid()` on
|
|
| 18 |
a `shared_future` object for which `valid() == false` is undefined.
|
| 19 |
|
| 20 |
[*Note 2*: It is valid to copy or move from a `shared_future` object
|
| 21 |
for which `valid()` is `false`. — *end note*]
|
| 22 |
|
| 23 |
-
|
| 24 |
-
of type `future_error` with an error condition of
|
| 25 |
-
`future_errc::no_state`.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
namespace std {
|
| 29 |
template<class R>
|
| 30 |
class shared_future {
|
|
@@ -50,10 +50,13 @@ namespace std {
|
|
| 50 |
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
|
| 51 |
};
|
| 52 |
}
|
| 53 |
```
|
| 54 |
|
|
|
|
|
|
|
|
|
|
| 55 |
The implementation provides the template `shared_future` and two
|
| 56 |
specializations, `shared_future<R&>` and `shared_future<void>`. These
|
| 57 |
differ only in the return type and return value of the member function
|
| 58 |
`get`, as set out in its description, below.
|
| 59 |
|
|
@@ -98,29 +101,31 @@ shared state that was originally referred to by `rhs` (if any).
|
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
shared_future& operator=(shared_future&& rhs) noexcept;
|
| 101 |
```
|
| 102 |
|
| 103 |
-
*Effects:*
|
|
|
|
| 104 |
|
| 105 |
- Releases any shared state [[futures.state]];
|
| 106 |
- move assigns the contents of `rhs` to `*this`.
|
| 107 |
|
| 108 |
*Ensures:*
|
| 109 |
|
| 110 |
- `valid()` returns the same value as `rhs.valid()` returned prior to
|
| 111 |
the assignment.
|
| 112 |
-
- `rhs.valid() == false`.
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
shared_future& operator=(const shared_future& rhs) noexcept;
|
| 116 |
```
|
| 117 |
|
| 118 |
-
*Effects:*
|
|
|
|
| 119 |
|
| 120 |
- Releases any shared state [[futures.state]];
|
| 121 |
-
- assigns the contents of `rhs` to `*this`. \[*Note
|
| 122 |
`*this` refers to the same shared state as `rhs` (if
|
| 123 |
any). — *end note*]
|
| 124 |
|
| 125 |
*Ensures:* `valid() == rhs.valid()`.
|
| 126 |
|
|
@@ -133,20 +138,20 @@ void shared_future<void>::get() const;
|
|
| 133 |
[*Note 1*: As described above, the template and its two required
|
| 134 |
specializations differ only in the return type and return value of the
|
| 135 |
member function `get`. — *end note*]
|
| 136 |
|
| 137 |
[*Note 2*: Access to a value object stored in the shared state is
|
| 138 |
-
unsynchronized, so
|
| 139 |
-
|
| 140 |
|
| 141 |
*Effects:* `wait()`s until the shared state is ready, then retrieves the
|
| 142 |
value stored in the shared state.
|
| 143 |
|
| 144 |
*Returns:*
|
| 145 |
|
| 146 |
- `shared_future::get()` returns a const reference to the value stored
|
| 147 |
-
in the object’s shared state. \[*Note
|
| 148 |
reference after the shared state has been destroyed produces undefined
|
| 149 |
behavior; this can be avoided by not storing the reference in any
|
| 150 |
storage with a greater lifetime than the `shared_future` object that
|
| 151 |
returned the reference. — *end note*]
|
| 152 |
- `shared_future<R&>::get()` returns the reference stored as value in
|
|
|
|
| 18 |
a `shared_future` object for which `valid() == false` is undefined.
|
| 19 |
|
| 20 |
[*Note 2*: It is valid to copy or move from a `shared_future` object
|
| 21 |
for which `valid()` is `false`. — *end note*]
|
| 22 |
|
| 23 |
+
*Recommended practice:* Implementations should detect this case and
|
| 24 |
+
throw an object of type `future_error` with an error condition of
|
| 25 |
+
`future_errc::no_state`.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
namespace std {
|
| 29 |
template<class R>
|
| 30 |
class shared_future {
|
|
|
|
| 50 |
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
|
| 51 |
};
|
| 52 |
}
|
| 53 |
```
|
| 54 |
|
| 55 |
+
For the primary template, `R` shall be an object type that meets the
|
| 56 |
+
*Cpp17Destructible* requirements.
|
| 57 |
+
|
| 58 |
The implementation provides the template `shared_future` and two
|
| 59 |
specializations, `shared_future<R&>` and `shared_future<void>`. These
|
| 60 |
differ only in the return type and return value of the member function
|
| 61 |
`get`, as set out in its description, below.
|
| 62 |
|
|
|
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
shared_future& operator=(shared_future&& rhs) noexcept;
|
| 104 |
```
|
| 105 |
|
| 106 |
+
*Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
|
| 107 |
+
Otherwise:
|
| 108 |
|
| 109 |
- Releases any shared state [[futures.state]];
|
| 110 |
- move assigns the contents of `rhs` to `*this`.
|
| 111 |
|
| 112 |
*Ensures:*
|
| 113 |
|
| 114 |
- `valid()` returns the same value as `rhs.valid()` returned prior to
|
| 115 |
the assignment.
|
| 116 |
+
- If `addressof(rhs) == this` is `false`, `rhs.valid() == false`.
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
shared_future& operator=(const shared_future& rhs) noexcept;
|
| 120 |
```
|
| 121 |
|
| 122 |
+
*Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
|
| 123 |
+
Otherwise:
|
| 124 |
|
| 125 |
- Releases any shared state [[futures.state]];
|
| 126 |
+
- assigns the contents of `rhs` to `*this`. \[*Note 3*: As a result,
|
| 127 |
`*this` refers to the same shared state as `rhs` (if
|
| 128 |
any). — *end note*]
|
| 129 |
|
| 130 |
*Ensures:* `valid() == rhs.valid()`.
|
| 131 |
|
|
|
|
| 138 |
[*Note 1*: As described above, the template and its two required
|
| 139 |
specializations differ only in the return type and return value of the
|
| 140 |
member function `get`. — *end note*]
|
| 141 |
|
| 142 |
[*Note 2*: Access to a value object stored in the shared state is
|
| 143 |
+
unsynchronized, so operations on `R` might introduce a data
|
| 144 |
+
race [[intro.multithread]]. — *end note*]
|
| 145 |
|
| 146 |
*Effects:* `wait()`s until the shared state is ready, then retrieves the
|
| 147 |
value stored in the shared state.
|
| 148 |
|
| 149 |
*Returns:*
|
| 150 |
|
| 151 |
- `shared_future::get()` returns a const reference to the value stored
|
| 152 |
+
in the object’s shared state. \[*Note 4*: Access through that
|
| 153 |
reference after the shared state has been destroyed produces undefined
|
| 154 |
behavior; this can be avoided by not storing the reference in any
|
| 155 |
storage with a greater lifetime than the `shared_future` object that
|
| 156 |
returned the reference. — *end note*]
|
| 157 |
- `shared_future<R&>::get()` returns the reference stored as value in
|