Skip to content

Commit

Permalink
Better?
Browse files Browse the repository at this point in the history
  • Loading branch information
brevzin committed Nov 23, 2024
1 parent 3280933 commit 7df7e6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ I believe this addresses all the implementor concerns with the original design.
## Wording
Extend [basic.scope.block]{.sref} to add `template` blocks:
::: std
[1]{.pnum} Each
* [1.1]{.pnum} selection or iteration statement ([stmt.select], [stmt.iter]),
* [1.2]{.pnum} substatement of such a statement,
* [1.*]{.pnum} [template block ([stmt.template]),]{.addu}
* [1.3]{.pnum} `$handler$` ([except.pre]), or
* [1.4]{.pnum} compound statement ([stmt.block]) that is not the `$compound-statement$` of a `$handler$`
introduces a *block scope* that includes that statement or handler.
:::
Extend the grammar for statement in [stmt.pre]{.sref}:
::: std
Expand All @@ -152,7 +138,7 @@ $template-block$:
$compound-statement$
```

A *template block* introduces an explicit template region ([temp.pre]).
A *template block* introduces an explicit template region ([temp.pre]) encompassing the block scope introduced by the `$compound-statement$`.

::: example
```cpp
Expand Down
46 changes: 10 additions & 36 deletions 3525_explicit_implicit_template_region/p3525r0.html
Original file line number Diff line number Diff line change
Expand Up @@ -737,33 +737,6 @@ <h1 data-number="2" style="border-bottom:1px solid #cccccc" id="proposal"><span
answering more complicated questions with other language features (like
member packs <span class="citation" data-cites="P3115R0">[<a href="https://wg21.link/p3115r0" role="doc-biblioref">P3115R0</a>]</span>).</p>
<h2 data-number="2.1" id="wording"><span class="header-section-number">2.1</span> Wording<a href="#wording" class="self-link"></a></h2>
<p>Extend <span>6.4.3 <a href="https://wg21.link/basic.scope.block">[basic.scope.block]</a></span>
to add
<code class="sourceCode cpp"><span class="kw">template</span></code>
blocks:</p>
<div class="std">
<blockquote>
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_1" id="pnum_1">1</a></span>
Each</p>
<ul>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_2" id="pnum_2">(1.1)</a></span>
selection or iteration statement ([stmt.select], [stmt.iter]),</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_3" id="pnum_3">(1.2)</a></span>
substatement of such a statement,</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_4" id="pnum_4">(1.*)</a></span>
<span class="addu">template block ([stmt.template]),</span></li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_5" id="pnum_5">(1.3)</a></span>
<code class="sourceCode cpp"><em>handler</em></code> ([except.pre]),
or</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_6" id="pnum_6">(1.4)</a></span>
compound statement ([stmt.block]) that is not the
<code class="sourceCode cpp"><em>compound-statement</em></code> of a
<code class="sourceCode cpp"><em>handler</em></code></li>
</ul>
<p>introduces a <em>block scope</em> that includes that statement or
handler.</p>
</blockquote>
</div>
<p>Extend the grammar for statement in <span>8.1 <a href="https://wg21.link/stmt.pre">[stmt.pre]</a></span>:</p>
<div class="std">
<blockquote>
Expand All @@ -789,7 +762,8 @@ <h2 data-number="2.1" id="wording"><span class="header-section-number">2.1</span
<div class="sourceCode" id="cb7"><pre class="sourceCode default"><code class="sourceCode default"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><em>template-block</em>:</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <em>compound-statement</em></span></code></pre></div>
<p>A <em>template block</em> introduces an explicit template region
([temp.pre]).</p>
([temp.pre]) encompassing the block scope introduced by the
<code class="sourceCode cpp"><em>compound-statement</em></code>.</p>
<div class="example">
<span><em>Example 1:</em> </span>
<div class="sourceCode" id="cb8"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> Point <span class="op">{</span> <span class="dt">int</span> x, y; <span class="op">}</span>;</span>
Expand All @@ -811,26 +785,26 @@ <h2 data-number="2.1" id="wording"><span class="header-section-number">2.1</span
in <span>13.1 <a href="https://wg21.link/temp.pre">[temp.pre]</a></span>:</p>
<div class="std">
<blockquote>
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_7" id="pnum_7">8</a></span>
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_1" id="pnum_1">8</a></span>
An entity is <em>templated</em> if it is</p>
<ul>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_8" id="pnum_8">(8.1)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_2" id="pnum_2">(8.1)</a></span>
a template,</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_9" id="pnum_9">(8.2)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_3" id="pnum_3">(8.2)</a></span>
an entity defined ([basic.def]) or created ([class.temporary]) in a
templated entity,</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_10" id="pnum_10">(8.3)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_4" id="pnum_4">(8.3)</a></span>
a member of a templated entity,</li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_11" id="pnum_11">(8.4)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_5" id="pnum_5">(8.4)</a></span>
an enumerator for an enumeration that is a templated entity, <span class="rm" style="color: #bf0303"><del>or</del></span></li>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_12" id="pnum_12">(8.5)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_6" id="pnum_6">(8.5)</a></span>
the closure type of a lambda-expression ([expr.prim.lambda.closure])
appearing in the declaration of a templated entity<span class="rm" style="color: #bf0303"><del>.</del></span> <span class="addu">,
or</span></li>
</ul>
<div class="addu">
<ul>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_13" id="pnum_13">(8.6)</a></span>
<li><span class="marginalizedparent"><a class="marginalized" href="#pnum_7" id="pnum_7">(8.6)</a></span>
an entity defined or created within an explicit template region
([stmt.template]).</li>
</ul>
Expand All @@ -844,7 +818,7 @@ <h2 data-number="2.1" id="wording"><span class="header-section-number">2.1</span
<p>Which needs a point of instantiation at the end of <span>13.8.4.1 <a href="https://wg21.link/temp.point">[temp.point]</a></span>:</p>
<div class="std ins">
<blockquote>
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_14" id="pnum_14">*</a></span>
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_8" id="pnum_8">*</a></span>
For an explicit template region, the point of instantiation immediately
follows the closing brace of the
<code class="sourceCode cpp"><em>compound-statement</em></code> of the
Expand Down

0 comments on commit 7df7e6e

Please sign in to comment.