tmp/tmpcwzx6ijd/{from.md → to.md}
RENAMED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
-
### [[stmt
|
| 2 |
|
| 3 |
**Change:** The lifetime of temporary objects in the
|
| 4 |
*for-range-initializer* is extended until the end of the loop
|
| 5 |
[[class.temporary]]. **Rationale:** Improve usability of the range-based
|
| 6 |
`for` statement. **Effect on original feature:** Destructors of some
|
| 7 |
-
temporary objects are invoked later.
|
|
|
|
|
|
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
void f() {
|
| 11 |
std::vector<int> v = { 42, 17, 13 };
|
| 12 |
std::mutex m;
|
|
@@ -16,5 +18,7 @@ void f() {
|
|
| 16 |
std::lock_guard<std::mutex> guard(m); // OK in C++20, now deadlocks
|
| 17 |
}
|
| 18 |
}
|
| 19 |
```
|
| 20 |
|
|
|
|
|
|
|
|
|
| 1 |
+
### [[stmt]]: statements <a id="diff.cpp20.stmt">[[diff.cpp20.stmt]]</a>
|
| 2 |
|
| 3 |
**Change:** The lifetime of temporary objects in the
|
| 4 |
*for-range-initializer* is extended until the end of the loop
|
| 5 |
[[class.temporary]]. **Rationale:** Improve usability of the range-based
|
| 6 |
`for` statement. **Effect on original feature:** Destructors of some
|
| 7 |
+
temporary objects are invoked later.
|
| 8 |
+
|
| 9 |
+
[*Example 1*:
|
| 10 |
|
| 11 |
``` cpp
|
| 12 |
void f() {
|
| 13 |
std::vector<int> v = { 42, 17, 13 };
|
| 14 |
std::mutex m;
|
|
|
|
| 18 |
std::lock_guard<std::mutex> guard(m); // OK in C++20, now deadlocks
|
| 19 |
}
|
| 20 |
}
|
| 21 |
```
|
| 22 |
|
| 23 |
+
— *end example*]
|
| 24 |
+
|