From Jason Turner

[futures.unique.future]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpepcazdb0/{from.md → to.md} +13 -9
tmp/tmpepcazdb0/{from.md → to.md} RENAMED
@@ -17,13 +17,13 @@ move-assignment operator, `share`, or `valid` on a `future` object for
17
  which `valid() == false` is undefined.
18
 
19
  [*Note 2*: It is valid to move from a future object for which
20
  `valid() == false`. — *end note*]
21
 
22
- [*Note 3*: Implementations should detect this case and throw an object
23
- of type `future_error` with an error condition of
24
- `future_errc::no_state`. — *end note*]
25
 
26
  ``` cpp
27
  namespace std {
28
  template<class R>
29
  class future {
@@ -49,10 +49,13 @@ namespace std {
49
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
50
  };
51
  }
52
  ```
53
 
 
 
 
54
  The implementation provides the template `future` and two
55
  specializations, `future<R&>` and `future<{}void>`. These differ only in
56
  the return type and return value of the member function `get`, as set
57
  out in its description, below.
58
 
@@ -88,29 +91,30 @@ state that was originally referred to by `rhs` (if any).
88
 
89
  ``` cpp
90
  future& operator=(future&& rhs) noexcept;
91
  ```
92
 
93
- *Effects:*
 
94
 
95
  - Releases any shared state [[futures.state]].
96
  - move assigns the contents of `rhs` to `*this`.
97
 
98
  *Ensures:*
99
 
100
  - `valid()` returns the same value as `rhs.valid()` prior to the
101
  assignment.
102
- - `rhs.valid() == false`.
103
 
104
  ``` cpp
105
  shared_future<R> share() noexcept;
106
  ```
107
 
 
 
108
  *Returns:* `shared_future<R>(std::move(*this))`.
109
 
110
- *Ensures:* `valid() == false`.
111
-
112
  ``` cpp
113
  R future::get();
114
  R& future<R&>::get();
115
  void future<void>::get();
116
  ```
@@ -123,10 +127,12 @@ member function `get`. — *end note*]
123
 
124
  - `wait()`s until the shared state is ready, then retrieves the value
125
  stored in the shared state;
126
  - releases any shared state [[futures.state]].
127
 
 
 
128
  *Returns:*
129
 
130
  - `future::get()` returns the value `v` stored in the object’s shared
131
  state as `std::move(v)`.
132
  - `future<R&>::get()` returns the reference stored as value in the
@@ -134,12 +140,10 @@ member function `get`. — *end note*]
134
  - `future<void>::get()` returns nothing.
135
 
136
  *Throws:* The stored exception, if an exception was stored in the shared
137
  state.
138
 
139
- *Ensures:* `valid() == false`.
140
-
141
  ``` cpp
142
  bool valid() const noexcept;
143
  ```
144
 
145
  *Returns:* `true` only if `*this` refers to a shared state.
 
17
  which `valid() == false` is undefined.
18
 
19
  [*Note 2*: It is valid to move from a future object for which
20
  `valid() == false`. — *end note*]
21
 
22
+ *Recommended practice:* Implementations should detect this case and
23
+ throw an object of type `future_error` with an error condition of
24
+ `future_errc::no_state`.
25
 
26
  ``` cpp
27
  namespace std {
28
  template<class R>
29
  class future {
 
49
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
50
  };
51
  }
52
  ```
53
 
54
+ For the primary template, `R` shall be an object type that meets the
55
+ *Cpp17Destructible* requirements.
56
+
57
  The implementation provides the template `future` and two
58
  specializations, `future<R&>` and `future<{}void>`. These differ only in
59
  the return type and return value of the member function `get`, as set
60
  out in its description, below.
61
 
 
91
 
92
  ``` cpp
93
  future& operator=(future&& rhs) noexcept;
94
  ```
95
 
96
+ *Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
97
+ Otherwise:
98
 
99
  - Releases any shared state [[futures.state]].
100
  - move assigns the contents of `rhs` to `*this`.
101
 
102
  *Ensures:*
103
 
104
  - `valid()` returns the same value as `rhs.valid()` prior to the
105
  assignment.
106
+ - If `addressof(rhs) == this` is `false`, `rhs.valid() == false`.
107
 
108
  ``` cpp
109
  shared_future<R> share() noexcept;
110
  ```
111
 
112
+ *Ensures:* `valid() == false`.
113
+
114
  *Returns:* `shared_future<R>(std::move(*this))`.
115
 
 
 
116
  ``` cpp
117
  R future::get();
118
  R& future<R&>::get();
119
  void future<void>::get();
120
  ```
 
127
 
128
  - `wait()`s until the shared state is ready, then retrieves the value
129
  stored in the shared state;
130
  - releases any shared state [[futures.state]].
131
 
132
+ *Ensures:* `valid() == false`.
133
+
134
  *Returns:*
135
 
136
  - `future::get()` returns the value `v` stored in the object’s shared
137
  state as `std::move(v)`.
138
  - `future<R&>::get()` returns the reference stored as value in the
 
140
  - `future<void>::get()` returns nothing.
141
 
142
  *Throws:* The stored exception, if an exception was stored in the shared
143
  state.
144
 
 
 
145
  ``` cpp
146
  bool valid() const noexcept;
147
  ```
148
 
149
  *Returns:* `true` only if `*this` refers to a shared state.