Skip to content

Commit 15dbd01

Browse files
committed
Ready to go
1 parent 58672df commit 15dbd01

File tree

4 files changed

+1740
-28
lines changed

4 files changed

+1740
-28
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
p3074r5.html : constexpr-union-lifetime.md
1+
p3074r6.html : constexpr-union-lifetime.md
22
include ../md/mpark-wg21.mk

3074_consexpr_union_lifetime/constexpr-union-lifetime.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "trivial `union`s (was `std::uninitialized<T>`)"
3-
document: P3074R5
3+
document: P3074R6
44
date: today
55
audience: EWG
66
author:
@@ -531,15 +531,15 @@ I was able to compile Clang with this update successfully, which wasn't particul
531531
Change [class.default.ctor]{.sref}/2-3. [The third and fourth bullets can be removed because such cases become trivially default constructible too]{.ednote}
532532

533533
::: std
534-
[2]{.pnum} A defaulted default constructor for class `X` is defined as deleted if [`X` is a non-union class and]{.addu}:
534+
[2]{.pnum} A defaulted default constructor for class `X` is defined as deleted if [`X` is a non-union class and]{.addu}
535535

536536
* [2.1]{.pnum} any non-static data member with no default member initializer ([class.mem]) is of reference type,
537537
* [2.2]{.pnum} any non-variant non-static data member of const-qualified type (or possibly multi-dimensional array thereof) with no brace-or-equal-initializer is not const-default-constructible ([dcl.init]),
538538
* [2.3]{.pnum} [`X` is a union and all of its variant members are of const-qualified type (or possibly multi-dimensional array thereof),]{.rm}
539539
* [2.4]{.pnum} [`X` is a non-union class and all members of any anonymous union member are of const-qualified type (or possibly multi-dimensional array thereof)]{.rm},
540540
* [2.5]{.pnum} any potentially constructed subobject, except for a non-static data member with a brace-or-equal-initializer [or a variant member of a union where another non-static data member has a brace-or-equal-initializer]{.rm}, has class type `M` (or possibly multi-dimensional array thereof) and overload resolution ([over.match]) as applied to find `M`'s corresponding constructor either does not result in a usable candidate ([over.match.general]) [or, in the case of a variant member, selects a non-trivial function,]{.rm} or
541541

542-
[3]{.pnum} A default constructor [for a class `X`]{.addu} is *trivial* if it is not user-provided and if:
542+
[3]{.pnum} A default constructor [for a class `X`]{.addu} is *trivial* if it is not user-provided and if[:]{.rm}
543543

544544
* [3.1]{.pnum} [its class]{.rm} [`X`]{.addu} has no virtual functions ([class.virtual]) and no virtual base classes ([class.mi]), and
545545
* [3.2]{.pnum} no non-static data member of [its class]{.rm} [`X`]{.addu} has a default member initializer ([class.mem]), and
@@ -554,20 +554,20 @@ Otherwise, the default constructor is *non-trivial*.
554554
Change [class.dtor]{.sref}/7-8:
555555

556556
::: std
557-
[7]{.pnum} A defaulted destructor for a class `X` is defined as deleted if:
557+
[7]{.pnum} A defaulted destructor for a class `X` is defined as deleted if[:]{.rm}
558558

559559
* [7.1]{.pnum} [`X` is a non-union class and]{.addu} any potentially constructed subobject has class type `M` (or possibly multi-dimensional array thereof) [and]{.rm} [where]{.addu} `M` has a destructor that is deleted or is inaccessible from the defaulted destructor [or, in the case of a variant member, is non-trivial]{.rm},
560560

561561
::: addu
562-
* [7.x]{.pnum} `X` is a union and either:
562+
* [7.x]{.pnum} `X` is a union and either
563563

564-
* [#.x.#]{.pnum} `X` has a user-provided default constructor, or
565-
* [#.x.#]{.pnum} `X` has a variant member `M` where `M` has a default member initializer and `M` has a destructor that is deleted, inaccessible from the defaulted destructor, or non-trivial,
564+
* [#.x.#]{.pnum} `X` does not have a default constructor that is defaulted on its first declaration,
565+
* [#.x.#]{.pnum} `X` has a variant member `V` of class type `M` (or possibly multi-dimensional array thereof) where `V` has a default member initializer and `M` has a destructor that is non-trivial, deleted, or inaccessible from the defaulted destructor,
566566
:::
567567

568568
* [7.2]{.pnum} or, for a virtual destructor, lookup of the non-array deallocation function results in an ambiguity or in a function that is deleted or inaccessible from the defaulted destructor.
569569

570-
[8]{.pnum} A destructor [for a class `X`]{.addu} is *trivial* if it is not user-provided and if:
570+
[8]{.pnum} A destructor [for a class `X`]{.addu} is *trivial* if it is not user-provided and if[:]{.rm}
571571

572572
* [8.1]{.pnum} the destructor is not virtual,
573573
* [8.2]{.pnum} all of the direct base classes of [its class]{.rm} [`X`]{.addu} have trivial destructors, and
@@ -597,7 +597,7 @@ Add a new macro to [cpp.predefined]{.sref}:
597597

598598
::: {.std .ins}
599599
```
600-
__cpp_trivial_union 2024XXL
600+
__cpp_trivial_union 2025XXL
601601
```
602602
:::
603603

@@ -606,6 +606,6 @@ And update the macro for `inplace_vector` in [version.syn]{.sref}:
606606
::: std
607607
```diff
608608
- #define __cpp_lib_inplace_vector 202406L // also in <inplace_vector>
609-
+ #define __cpp_lib_inplace_vector 2024XXL // also in <inplace_vector>
609+
+ #define __cpp_lib_inplace_vector 2025XXL // also in <inplace_vector>
610610
```
611611
:::

3074_consexpr_union_lifetime/p3074r5.html

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" />
55
<meta name="generator" content="mpark/wg21" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
7-
<meta name="dcterms.date" content="2024-12-16" />
7+
<meta name="dcterms.date" content="2025-02-11" />
88
<title>trivial unions (was std::uninitialized&lt;T&gt;)</title>
99
<style>
1010
code{white-space: pre-wrap;}
@@ -448,6 +448,9 @@
448448
td > div.sourceCode {
449449
background-color: inherit;
450450
}
451+
td > div > div.sourceCode {
452+
background-color: inherit;
453+
}
451454
table {
452455
border-collapse: collapse;
453456
}
@@ -567,7 +570,7 @@ <h1 class="title" style="text-align:center">trivial
567570
</tr>
568571
<tr>
569572
<td>Date:</td>
570-
<td>2024-12-16</td>
573+
<td>2025-02-11</td>
571574
</tr>
572575
<tr>
573576
<td style="vertical-align:top">Project:</td>
@@ -632,10 +635,10 @@ <h1 id="toctitle">Contents</h1>
632635
</div>
633636
<h1 data-number="1" style="border-bottom:1px solid #cccccc" id="revision-history"><span class="header-section-number">1</span>
634637
Revision History<a href="#revision-history" class="self-link"></a></h1>
635-
<p>Since <span class="citation" data-cites="P3074R4">[<a href="https://wg21.link/p3074r4" role="doc-biblioref">P3074R4</a>]</span>, wording changes and adjusted
638+
<p>Since <span class="citation" data-cites="P3074R4"><a href="https://wg21.link/p3074r4" role="doc-biblioref">[P3074R4]</a></span>, wording changes and adjusted
636639
the rule for when a <a href="#constructordestructor-intention-matching">union’s destructor is
637640
deleted</a></p>
638-
<p>Since <span class="citation" data-cites="P3074R3">[<a href="https://wg21.link/p3074r3" role="doc-biblioref">P3074R3</a>]</span>, in <a href="https://github.com/cplusplus/papers/issues/1734#issuecomment-2195769496">St. Louis</a>,
641+
<p>Since <span class="citation" data-cites="P3074R3"><a href="https://wg21.link/p3074r3" role="doc-biblioref">[P3074R3]</a></span>, in <a href="https://github.com/cplusplus/papers/issues/1734#issuecomment-2195769496">St. Louis</a>,
639642
EWG had expressed a clear preference for “just make it work”:</p>
640643
<table>
641644
<thead>
@@ -699,15 +702,15 @@ <h1 data-number="1" style="border-bottom:1px solid #cccccc" id="revision-history
699702
</tbody>
700703
</table>
701704
<p>So proposing to make it work and adding <a href="#implementation-experience">implementation experience</a>.</p>
702-
<p>Since <span class="citation" data-cites="P3074R2">[<a href="https://wg21.link/p3074r2" role="doc-biblioref">P3074R2</a>]</span>, changed to instead propose a
705+
<p>Since <span class="citation" data-cites="P3074R2"><a href="https://wg21.link/p3074r2" role="doc-biblioref">[P3074R2]</a></span>, changed to instead propose a
703706
language change to unions (with two options) to solve the problems
704707
presented</p>
705-
<p>Since <span class="citation" data-cites="P3074R1">[<a href="https://wg21.link/p3074r1" role="doc-biblioref">P3074R1</a>]</span>, the <code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">&gt;</span></code>
708+
<p>Since <span class="citation" data-cites="P3074R1"><a href="https://wg21.link/p3074r1" role="doc-biblioref">[P3074R1]</a></span>, the <code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">&gt;</span></code>
706709
design was designed in an EWG telecon and the suggestion was made to
707710
make this a language feature. Added a section to argue against and
708711
re-spelled <code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">&gt;</span></code>
709712
to be a union instead of a class containing an anonymous union.</p>
710-
<p>Since <span class="citation" data-cites="P3074R0">[<a href="https://wg21.link/p3074r0" role="doc-biblioref">P3074R0</a>]</span>, originally proposed the
713+
<p>Since <span class="citation" data-cites="P3074R0"><a href="https://wg21.link/p3074r0" role="doc-biblioref">[P3074R0]</a></span>, originally proposed the
711714
function <code class="sourceCode cpp">std<span class="op">::</span>start_lifetime<span class="op">(</span>p<span class="op">)</span></code>.
712715
R1 adds a new section discussing the <a href="#the-uninitialized-storage-problem">uninitialized storage
713716
problem</a>, which motivates a change in design to instead propose <code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">&gt;</span></code>.</p>
@@ -750,10 +753,10 @@ <h1 data-number="2" style="border-bottom:1px solid #cccccc" id="introduction"><s
750753
MSVC and EDG accept it and GCC did accept it even up to 13.2, but GCC
751754
trunk and Clang reject).</p>
752755
<p>Getting this example to work would allow <code class="sourceCode cpp">std<span class="op">::</span>inplace_vector</code>
753-
(<span class="citation" data-cites="P0843R14">[<a href="https://wg21.link/p0843r14" role="doc-biblioref">P0843R14</a>]</span>) to simply work during
756+
(<span class="citation" data-cites="P0843R14"><a href="https://wg21.link/p0843r14" role="doc-biblioref">[P0843R14]</a></span>) to simply work during
754757
<code class="sourceCode cpp"><span class="kw">constexpr</span></code>
755758
time for all times (instead of just trivial ones), and was a problem
756-
briefly touched on in <span class="citation" data-cites="P2747R0">[<a href="https://wg21.link/p2747r0" role="doc-biblioref">P2747R0</a>]</span>.</p>
759+
briefly touched on in <span class="citation" data-cites="P2747R0"><a href="https://wg21.link/p2747r0" role="doc-biblioref">[P2747R0]</a></span>.</p>
757760
<h2 data-number="2.1" id="the-uninitialized-storage-problem"><span class="header-section-number">2.1</span> The uninitialized storage
758761
problem<a href="#the-uninitialized-storage-problem" class="self-link"></a></h2>
759762
<p>A closely related problem to the above is: how do you do
@@ -957,16 +960,16 @@ <h1 data-number="3" style="border-bottom:1px solid #cccccc" id="design-space"><s
957960
<li>provide an explicit function to start lifetime of a union
958961
alternative (<code class="sourceCode cpp">std<span class="op">::</span>start_lifetime</code>).</li>
959962
</ol>
960-
<p>The first revision of this paper (<span class="citation" data-cites="P3074R0">[<a href="https://wg21.link/p3074r0" role="doc-biblioref">P3074R0</a>]</span>) proposed that last option.
963+
<p>The first revision of this paper (<span class="citation" data-cites="P3074R0"><a href="https://wg21.link/p3074r0" role="doc-biblioref">[P3074R0]</a></span>) proposed that last option.
961964
However, with the addition of the overlapping subobjects problem and the
962965
realization that the union solution has overhead compared to the buffer
963966
storage solution, it would be more desirable to solve both problems in
964967
one go. That is, it’s not enough to just start the lifetime of the
965968
alternative, we also want a trivially constructible/destructible
966969
solution for uninitialized storage.</p>
967-
<p><span class="citation" data-cites="P3074R1">[<a href="https://wg21.link/p3074r1" role="doc-biblioref">P3074R1</a>]</span> and <span class="citation" data-cites="P3074R2">[<a href="https://wg21.link/p3074r2" role="doc-biblioref">P3074R2</a>]</span> proposed the first solution
970+
<p><span class="citation" data-cites="P3074R1"><a href="https://wg21.link/p3074r1" role="doc-biblioref">[P3074R1]</a></span> and <span class="citation" data-cites="P3074R2"><a href="https://wg21.link/p3074r2" role="doc-biblioref">[P3074R2]</a></span> proposed the first solution
968971
(<code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">&gt;</span></code>).
969-
<span class="citation" data-cites="P3074R3">[<a href="https://wg21.link/p3074r3" role="doc-biblioref">P3074R3</a>]</span> proposed either the third or
972+
<span class="citation" data-cites="P3074R3"><a href="https://wg21.link/p3074r3" role="doc-biblioref">[P3074R3]</a></span> proposed either the third or
970973
fourth. This revision (R4) proposes specifically the third (just make it
971974
work).</p>
972975
<p>Let’s go over some of the solutions.</p>
@@ -994,8 +997,9 @@ <h2 data-number="3.1" id="a-library-type-stduninitializedt"><span class="header-
994997
<p><code class="sourceCode cpp">std<span class="op">::</span>inplace_vector<span class="op">&lt;</span>T, N<span class="op">&gt;</span></code>
995998
would then have a <code class="sourceCode cpp">std<span class="op">::</span>uninitialized<span class="op">&lt;</span>T<span class="op">[</span>N<span class="op">]&gt;</span></code>
996999
and go ahead and <code class="sourceCode cpp">std<span class="op">::</span>construct_at</code>
997-
(or, with <span class="citation" data-cites="P2747R2">[<a href="https://wg21.link/p2747r2" role="doc-biblioref">P2747R2</a>]</span>, simply placement-new) into the
998-
appropriate elements of that array and everything would just work.</p>
1000+
(or, with <span class="citation" data-cites="P2747R2"><a href="https://wg21.link/p2747r2" role="doc-biblioref">[P2747R2]</a></span>, simply placement-new) into
1001+
the appropriate elements of that array and everything would just
1002+
work.</p>
9991003
<p>Because the language would recognize this type, this would also solve
10001004
the overlapping objects problem.</p>
10011005
<h2 data-number="3.2" id="a-language-annotation"><span class="header-section-number">3.2</span> A language annotation<a href="#a-language-annotation" class="self-link"></a></h2>
@@ -1272,7 +1276,7 @@ <h2 data-number="3.5" id="existing-practice"><span class="header-section-number"
12721276
purpose.</p>
12731277
<h2 data-number="3.6" id="st.-louis-meeting-2024"><span class="header-section-number">3.6</span> St. Louis Meeting, 2024<a href="#st.-louis-meeting-2024" class="self-link"></a></h2>
12741278
<p>In <a href="https://github.com/cplusplus/papers/issues/1734#issuecomment-2195769496">St. Louis</a>,
1275-
we discussed a previous revision of this paper (<span class="citation" data-cites="P3074R3">[<a href="https://wg21.link/p3074r3" role="doc-biblioref">P3074R3</a>]</span>), specifically the <a href="#trivial-unions">trivial union</a> and <a href="#just-make-it-work">just make it work</a> designs. There, EWG
1279+
we discussed a previous revision of this paper (<span class="citation" data-cites="P3074R3"><a href="https://wg21.link/p3074r3" role="doc-biblioref">[P3074R3]</a></span>), specifically the <a href="#trivial-unions">trivial union</a> and <a href="#just-make-it-work">just make it work</a> designs. There, EWG
12761280
expressed a clear preference for “just make it work”:</p>
12771281
<table>
12781282
<thead>
@@ -1627,11 +1631,11 @@ <h2 data-number="4.2" id="language-wording"><span class="header-section-number">
16271631
</blockquote>
16281632
</div>
16291633
<h2 data-number="4.3" id="library-wording"><span class="header-section-number">4.3</span> Library Wording<a href="#library-wording" class="self-link"></a></h2>
1630-
<p>While this paper was in flight, <span class="citation" data-cites="P0843R14">[<a href="https://wg21.link/p0843r14" role="doc-biblioref">P0843R14</a>]</span> was moved, which had to work
1634+
<p>While this paper was in flight, <span class="citation" data-cites="P0843R14"><a href="https://wg21.link/p0843r14" role="doc-biblioref">[P0843R14]</a></span> was moved, which had to work
16311635
around the lack of ability to actually support non-trivial types during
16321636
constant evaluation. Since this paper now provides that, might as well
16331637
fix the library to account for the new functionality.</p>
1634-
<p>Strike <span>24.3.14.1 <a href="https://wg21.link/inplace.vector.overview">[inplace.vector.overview]</a></span>/4:</p>
1638+
<p>Strike <span>23.3.14.1 <a href="https://wg21.link/inplace.vector.overview">[inplace.vector.overview]</a></span>/4:</p>
16351639
<div class="std">
16361640
<blockquote>
16371641
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_23" id="pnum_23">3</a></span>

0 commit comments

Comments
 (0)