|
2 | 2 | <!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
3 | 3 |
|
4 | 4 | <issue num="4479" status="New"> |
5 | | -<title>No restrictions on which types can be `tuple` elements</title> |
| 5 | +<title>Missing restrictions on which types can be `tuple` elements</title> |
6 | 6 | <section><sref ref="[tuple.tuple.general]"/></section> |
7 | 7 | <submitter>Davis Herring</submitter> |
8 | 8 | <date>21 Nov 2025</date> |
9 | 9 | <priority>99</priority> |
10 | 10 |
|
11 | 11 | <discussion> |
12 | 12 | <p> |
13 | | -We do not prohibit nonsense like <code>std::tuple<void></code> |
14 | | -or <code>std::tuple<int()></code>. |
| 13 | +We do not say that instantiating types like <code>std::tuple<void></code> |
| 14 | +or <code>std::tuple<int()></code> won't work. |
| 15 | +</p> |
| 16 | + |
| 17 | + |
| 18 | +<note>2025-11-26; Jonathan comments.</note> |
| 19 | +<p> |
| 20 | +<sref ref="[res.on.functions]"/> already makes it undefined behaviour to |
| 21 | +instantiate `tuple` with an incomplete type, which includes `void` and `int[]`. |
| 22 | +It would be better if it was ill-formed not undefined though, and that doesn't |
| 23 | +say anything about <code>tuple<int()></code> or |
| 24 | +<code>tuple<AbstractClassType></code>. |
| 25 | +Any restrictions should only apply when `tuple` is instantiated, |
| 26 | +not just when it's declared, as that would prevent using it as a typelist. |
| 27 | +</p> |
| 28 | +<p> |
| 29 | +We might need to specify that `tuple_size` and `tuple_element` can be |
| 30 | +instantiated with incomplete types that are specializations of `tuple`, |
| 31 | +because otherwise <sref ref="[res.on.functions]"/> makes that undefined. |
| 32 | +`tuple_size` and `tuple_element` don't need a complete `tuple` type |
| 33 | +to give an answer, and they don't need to instantiate a `tuple` type. |
| 34 | +So <code>tuple_element_t<0, tuple<void>></code> should work. |
15 | 35 | </p> |
16 | 36 | </discussion> |
17 | 37 |
|
|
0 commit comments