Skip to content

Commit

Permalink
Some more work on wording
Browse files Browse the repository at this point in the history
  • Loading branch information
brevzin committed Nov 5, 2024
1 parent 1a50372 commit 122157a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
18 changes: 11 additions & 7 deletions 3380_extend_cnttp_2/extend-cnttp-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,8 @@ First, as with [@P2484R0], I'm referring to `to_meta_representation` as a templa
a. `R.data()` is convertible to `std::meta::info const*`, `R.size()` is convertible to `size_t`, and `static_cast<std::meta::info const*>(R.data())[i]` shall be valid for all `0 <= i < static_cast<size_t>(R.size())`, and
b. `T::from_meta_representation(R)` is a valid expression that yields a prvalue of type `T`.
We'll say that `T` has an eligible template registration function if it provides `to_meta_representation` as a direct member of the one of the allowed forms.
Either way, no non-static data member of `T` can be `mutable`.
Second, we introduce the concept of template argument normalization and allow string literal template arguments:
Expand Down Expand Up @@ -795,24 +797,26 @@ A *structural type* is one of the following:
* [7.1]{.pnum} a scalar type, or
* [7.2]{.pnum} an lvalue reference type, or
* [7.2b]{.pnum} [an array type whose element type is structural, or]{.addu}
* [7.3]{.pnum} a literal class type with the following properties:
* [7.3.0]{.pnum} [the class has an eligible template representation function, or]{.addu}
* [7.3.1]{.pnum} all base classes and non-static data members are public and non-mutable and
* [7.3.2]{.pnum} the types of all bases classes and non-static data members are structural types [or (possibly multidimensional) array thereof]{.rm}.
* [7.3]{.pnum} a literal class [`C`]{.addu} type with the following properties:
* [7.3.0]{.pnum} [`C` has an eligible template representation function, or ]{.addu}
* [7.3.1]{.pnum} all base classes and non-static data members [of `C`]{.addu} are public and non-mutable and
* [7.3.2]{.pnum} the types of all bases classes and non-static data members [of `C`]{.addu} are structural types [or (possibly multidimensional) array thereof]{.rm}.
:::
Fifth, we extend the definition of *template-argument-equivalent* (note that two values of type `std::meta::info` that represent values compare equal if those values are template-argument-equivalent, so this definition is properly recursive):
Fifth, ensure that when initializing a non-type template parameter of class type, that we perform template-argument-normalization.
Sixth, we extend the definition of *template-argument-equivalent*. Note that two values of type `std::meta::info` that represent values compare equal if those values are template-argument-equivalent, so this definition is properly recursive. Also note that normalization will have already happened, so we don't need to talk about the `void`-returning case of `to_meta_representation` here.
::: std
Two values are *template-argument-equivalent* if they are of the same type and [...]
* [2.11]{.pnum} they are of class type [`T`]{.addu} and
* [2.11.1]{.pnum} [If `T` has an eligible template representation function that returns non-`void`, then let `r1` and `r2` be the results of invoking the template registration function on the two values. The values are considered template argument equivalent if `r1.size() == r2.size()` and, for each `i` such that `0 <= i < r1.size()`, `r1.data()[i] == r2.data()[i]`.]{.addu}
* [2.11.1]{.pnum} [If `T` has a eligible template representation function that returns non-`void`, then let `r1` and `r2` be the results of invoking the template registration function on the two values. The values are considered template argument equivalent if `r1.size() == r2.size()` and, for each `i` such that `0 <= i < r1.size()`, `r1.data()[i] == r2.data()[i]`.]{.addu}
* [2.11.2]{.pnum} [Otherwise, if]{.addu} their corresponding direct subobjects and reference members are template-argument-equivalent.
:::
Sixth, ensure that when initializing a non-type template parameter of class type, that we perform template-argument-normalization (so that the above rule on equivalence is only ever performed on normalized values).
## Library
Expand Down
40 changes: 24 additions & 16 deletions 3380_extend_cnttp_2/p3380r1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="generator" content="mpark/wg21" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="dcterms.date" content="2024-11-04" />
<meta name="dcterms.date" content="2024-11-05" />
<title>Extending support for class types as non-type template
parameters</title>
<style>
Expand Down Expand Up @@ -567,7 +567,7 @@ <h1 class="title" style="text-align:center">Extending support for class
</tr>
<tr>
<td>Date:</td>
<td>2024-11-04</td>
<td>2024-11-05</td>
</tr>
<tr>
<td style="vertical-align:top">Project:</td>
Expand Down Expand Up @@ -1558,6 +1558,10 @@ <h2 data-number="4.1" id="language"><span class="header-section-number">4.1</spa
<code class="sourceCode cpp">T</code>.</li>
</ol></li>
</ol>
<p>We’ll say that <code class="sourceCode cpp">T</code> has an eligible
template registration function if it provides
<code class="sourceCode cpp">to_meta_representation</code> as a direct
member of the one of the allowed forms.</p>
<p>Either way, no non-static data member of
<code class="sourceCode cpp">T</code> can be
<code class="sourceCode cpp"><span class="kw">mutable</span></code>.</p>
Expand Down Expand Up @@ -1661,28 +1665,36 @@ <h2 data-number="4.1" id="language"><span class="header-section-number">4.1</spa
<span class="addu">an array type whose element type is structural,
or</span></li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_17" id="pnum_17">(7.3)</a></span>
a literal class type with the following properties:
a literal class <span class="addu"><code class="sourceCode cpp">C</code></span> type with the
following properties:
<ul>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_18" id="pnum_18">(7.3.0)</a></span>
<span class="addu">the class has an eligible template representation
function, or</span></li>
<span class="addu"><code class="sourceCode cpp">C</code> has an eligible
template representation function, or</span></li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_19" id="pnum_19">(7.3.1)</a></span>
all base classes and non-static data members are public and non-mutable
all base classes and non-static data members <span class="addu">of
<code class="sourceCode cpp">C</code></span> are public and non-mutable
and</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_20" id="pnum_20">(7.3.2)</a></span>
the types of all bases classes and non-static data members are
the types of all bases classes and non-static data members <span class="addu">of <code class="sourceCode cpp">C</code></span> are
structural types <span class="rm" style="color: #bf0303"><del>or
(possibly multidimensional) array thereof</del></span>.</li>
</ul></li>
</ul>
</blockquote>
</div>
<p>Fifth, we extend the definition of
<em>template-argument-equivalent</em> (note that two values of type
<p>Fifth, ensure that when initializing a non-type template parameter of
class type, that we perform template-argument-normalization.</p>
<p>Sixth, we extend the definition of
<em>template-argument-equivalent</em>. Note that two values of type
<code class="sourceCode cpp">std<span class="op">::</span>meta<span class="op">::</span>info</code>
that represent values compare equal if those values are
template-argument-equivalent, so this definition is properly
recursive):</p>
template-argument-equivalent, so this definition is properly recursive.
Also note that normalization will have already happened, so we don’t
need to talk about the
<code class="sourceCode cpp"><span class="dt">void</span></code>-returning
case of <code class="sourceCode cpp">to_meta_representation</code>
here.</p>
<div class="std">
<blockquote>
<p>Two values are <em>template-argument-equivalent</em> if they are of
Expand All @@ -1692,7 +1704,7 @@ <h2 data-number="4.1" id="language"><span class="header-section-number">4.1</spa
they are of class type <span class="addu"><code class="sourceCode cpp">T</code></span> and</p>
<ul>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_22" id="pnum_22">(2.11.1)</a></span>
<span class="addu">If <code class="sourceCode cpp">T</code> has an
<span class="addu">If <code class="sourceCode cpp">T</code> has a
eligible template representation function that returns
non-<code class="sourceCode cpp"><span class="dt">void</span></code>,
then let <code class="sourceCode cpp">r1</code> and
Expand All @@ -1708,10 +1720,6 @@ <h2 data-number="4.1" id="language"><span class="header-section-number">4.1</spa
</ul>
</blockquote>
</div>
<p>Sixth, ensure that when initializing a non-type template parameter of
class type, that we perform template-argument-normalization (so that the
above rule on equivalence is only ever performed on normalized
values).</p>
<h2 data-number="4.2" id="library"><span class="header-section-number">4.2</span> Library<a href="#library" class="self-link"></a></h2>
<p>Add a new type trait for <code class="sourceCode cpp">std<span class="op">::</span>is_structural</code>,
which we will need to provide constrained template registration
Expand Down

0 comments on commit 122157a

Please sign in to comment.