tmp/tmpulpl25q6/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### [[containers]]: containers library <a id="diff.cpp23.containers">[[diff.cpp23.containers]]</a>
|
| 2 |
+
|
| 3 |
+
**Change:** `span<const T>` is constructible from `initializer_list<T>`.
|
| 4 |
+
**Rationale:** Permit passing a braced initializer list to a function
|
| 5 |
+
taking `span`. **Effect on original feature:** Valid C++23 code that
|
| 6 |
+
relies on the lack of this constructor may refuse to compile, or change
|
| 7 |
+
behavior in this revision of C++.
|
| 8 |
+
|
| 9 |
+
[*Example 1*:
|
| 10 |
+
|
| 11 |
+
``` cpp
|
| 12 |
+
void one(pair<int, int>); // #1
|
| 13 |
+
void one(span<const int>); // #2
|
| 14 |
+
void t1() { one({1, 2}); } // ambiguous between #1 and #2; previously called #1
|
| 15 |
+
|
| 16 |
+
void two(span<const int, 2>);
|
| 17 |
+
void t2() { two({{1, 2}}); } // ill-formed; previously well-formed
|
| 18 |
+
|
| 19 |
+
void *a[10];
|
| 20 |
+
int x = span<void* const>{a, 0}.size(); // x is 2; previously 0
|
| 21 |
+
any b[10];
|
| 22 |
+
int y = span<const any>{b, b + 10}.size(); // y is 2; previously 10
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
— *end example*]
|
| 26 |
+
|