<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
  <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="2023-02-07" />
  <title>Fix layout mappings all static extent default constructor</title>
  <style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
  <style>
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ background-color: #f6f8fa; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { } 
code span.al { color: #ff0000; } 
code span.an { } 
code span.at { } 
code span.bn { color: #9f6807; } 
code span.bu { color: #9f6807; } 
code span.cf { color: #00607c; } 
code span.ch { color: #9f6807; } 
code span.cn { } 
code span.co { color: #008000; font-style: italic; } 
code span.cv { color: #008000; font-style: italic; } 
code span.do { color: #008000; } 
code span.dt { color: #00607c; } 
code span.dv { color: #9f6807; } 
code span.er { color: #ff0000; font-weight: bold; } 
code span.ex { } 
code span.fl { color: #9f6807; } 
code span.fu { } 
code span.im { } 
code span.in { color: #008000; } 
code span.kw { color: #00607c; } 
code span.op { color: #af1915; } 
code span.ot { } 
code span.pp { color: #6f4e37; } 
code span.re { } 
code span.sc { color: #9f6807; } 
code span.ss { color: #9f6807; } 
code span.st { color: #9f6807; } 
code span.va { } 
code span.vs { color: #9f6807; } 
code span.wa { color: #008000; font-weight: bold; } 
code.diff {color: #898887}
code.diff span.va {color: #6.0e28}
code.diff span.st {color: #bf0303}
</style>
  <style type="text/css">
body {
margin: 5em;
font-family: serif;

hyphens: auto;
line-height: 1.35;
}
div.wrapper {
max-width: 60em;
margin: auto;
}
ul {
list-style-type: none;
padding-left: 2em;
margin-top: -0.2em;
margin-bottom: -0.2em;
}
a {
text-decoration: none;
color: #4183C4;
}
a.hidden_link {
text-decoration: none;
color: inherit;
}
li {
margin-top: 0.6em;
margin-bottom: 0.6em;
}
h1, h2, h3, h4 {
position: relative;
line-height: 1;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
font-family: sans-serif;
font-weight: normal;
font-size: 83%;
}
a.self-link:hover { opacity: 1; }
a.self-link::before { content: "§"; }
ul > li:before {
content: "\2014";
position: absolute;
margin-left: -1.5em;
}
:target { background-color: #C9FBC9; }
:target .codeblock { background-color: #C9FBC9; }
:target ul { background-color: #C9FBC9; }
.abbr_ref { float: right; }
.folded_abbr_ref { float: right; }
:target .folded_abbr_ref { display: none; }
:target .unfolded_abbr_ref { float: right; display: inherit; }
.unfolded_abbr_ref { display: none; }
.secnum { display: inline-block; min-width: 35pt; }
.header-section-number { display: inline-block; min-width: 35pt; }
.annexnum { display: block; }
div.sourceLinkParent {
float: right;
}
a.sourceLink {
position: absolute;
opacity: 0;
margin-left: 10pt;
}
a.sourceLink:hover {
opacity: 1;
}
a.itemDeclLink {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
opacity: 0;
}
a.itemDeclLink:hover { opacity: 1; }
span.marginalizedparent {
position: relative;
left: -5em;
}
li span.marginalizedparent { left: -7em; }
li ul > li span.marginalizedparent { left: -9em; }
li ul > li ul > li span.marginalizedparent { left: -11em; }
li ul > li ul > li ul > li span.marginalizedparent { left: -13em; }
div.footnoteNumberParent {
position: relative;
left: -4.7em;
}
a.marginalized {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
}
a.enumerated_item_num {
position: relative;
left: -3.5em;
display: inline-block;
margin-right: -3em;
text-align: right;
width: 3em;
}
div.para { margin-bottom: 0.6em; margin-top: 0.6em; text-align: justify; }
div.section { text-align: justify; }
div.sentence { display: inline; }
span.indexparent {
display: inline;
position: relative;
float: right;
right: -1em;
}
a.index {
position: absolute;
display: none;
}
a.index:before { content: "⟵"; }

a.index:target {
display: inline;
}
.indexitems {
margin-left: 2em;
text-indent: -2em;
}
div.itemdescr {
margin-left: 3em;
}
.bnf {
font-family: serif;
margin-left: 40pt;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.ncbnf {
font-family: serif;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
}
.ncsimplebnf {
font-family: serif;
font-style: italic;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
background: inherit; 
}
span.textnormal {
font-style: normal;
font-family: serif;
white-space: normal;
display: inline-block;
}
span.rlap {
display: inline-block;
width: 0px;
}
span.descr { font-style: normal; font-family: serif; }
span.grammarterm { font-style: italic; }
span.term { font-style: italic; }
span.terminal { font-family: monospace; font-style: normal; }
span.nonterminal { font-style: italic; }
span.tcode { font-family: monospace; font-style: normal; }
span.textbf { font-weight: bold; }
span.textsc { font-variant: small-caps; }
a.nontermdef { font-style: italic; font-family: serif; }
span.emph { font-style: italic; }
span.techterm { font-style: italic; }
span.mathit { font-style: italic; }
span.mathsf { font-family: sans-serif; }
span.mathrm { font-family: serif; font-style: normal; }
span.textrm { font-family: serif; }
span.textsl { font-style: italic; }
span.mathtt { font-family: monospace; font-style: normal; }
span.mbox { font-family: serif; font-style: normal; }
span.ungap { display: inline-block; width: 2pt; }
span.textit { font-style: italic; }
span.texttt { font-family: monospace; }
span.tcode_in_codeblock { font-family: monospace; font-style: normal; }
span.phantom { color: white; }

span.math { font-style: normal; }
span.mathblock {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 1.2em;
margin-bottom: 1.2em;
text-align: center;
}
span.mathalpha {
font-style: italic;
}
span.synopsis {
font-weight: bold;
margin-top: 0.5em;
display: block;
}
span.definition {
font-weight: bold;
display: block;
}
.codeblock {
margin-left: 1.2em;
line-height: 127%;
}
.outputblock {
margin-left: 1.2em;
line-height: 127%;
}
div.itemdecl {
margin-top: 2ex;
}
code.itemdeclcode {
white-space: pre;
display: block;
}
span.textsuperscript {
vertical-align: super;
font-size: smaller;
line-height: 0;
}
.footnotenum { vertical-align: super; font-size: smaller; line-height: 0; }
.footnote {
font-size: small;
margin-left: 2em;
margin-right: 2em;
margin-top: 0.6em;
margin-bottom: 0.6em;
}
div.minipage {
display: inline-block;
margin-right: 3em;
}
div.numberedTable {
text-align: center;
margin: 2em;
}
div.figure {
text-align: center;
margin: 2em;
}
table {
border: 1px solid black;
border-collapse: collapse;
margin-left: auto;
margin-right: auto;
margin-top: 0.8em;
text-align: left;
hyphens: none; 
}
td, th {
padding-left: 1em;
padding-right: 1em;
vertical-align: top;
}
td.empty {
padding: 0px;
padding-left: 1px;
}
td.left {
text-align: left;
}
td.right {
text-align: right;
}
td.center {
text-align: center;
}
td.justify {
text-align: justify;
}
td.border {
border-left: 1px solid black;
}
tr.rowsep, td.cline {
border-top: 1px solid black;
}
tr.even, tr.odd {
border-bottom: 1px solid black;
}
tr.capsep {
border-top: 3px solid black;
border-top-style: double;
}
tr.header {
border-bottom: 3px solid black;
border-bottom-style: double;
}
th {
border-bottom: 1px solid black;
}
span.centry {
font-weight: bold;
}
div.table {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 90%;
}
span.indented {
display: block;
margin-left: 2em;
margin-bottom: 1em;
margin-top: 1em;
}
ol.enumeratea { list-style-type: none; background: inherit; }
ol.enumerate { list-style-type: none; background: inherit; }

code.sourceCode > span { display: inline; }

div#refs p { padding-left: 32px; text-indent: -32px; }
</style>
  <link href="data:text/html; charset=utf-8;charset=utf-8,%3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3EBIG%2DIP%20Per%20Request%20Policy%20Resource%20blocked%20page%3C%2Ftitle%3E%0A%3Cstyle%3E%0Abody%2C%20html%20%7B%0A%20%20%20%20padding%3A%200%3B%0A%20%20%20%20margin%3A%200%3B%0A%20%20%20%20height%3A%20100%25%3B%0A%7D%0Atable%2C%20td%2C%20th%2C%20div%20%7B%0A%20%20%20%20border%3A%200%3B%0A%20%20%20%20padding%3A%200%3B%0A%20%20%20%20margin%3A%200%3B%0A%7D%0Abody%2C%20table%2C%20td%2C%20th%2C%20div%2C%20input%2C%20h1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%20%7B%0A%20%20%20%20font%2Dfamily%20%3A%20Calibri%2C%20Tahoma%2C%20Verdana%2C%20Arial%2C%20Helvetica%2C%20Sans%2DSerif%3B%0A%20%20%20%20color%3A%20%23000000%3B%0A%20%20%20%20text%2Dalign%3A%20center%3B%0A%7D%0Abody%2C%20table%2C%20td%2C%20th%2C%20div%2C%20input%20%7B%0A%20%20%20%20font%2Dsize%20%3A%2014px%3B%0A%7D%0Ah1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%20%7B%0A%20%20%20%20font%2Dsize%20%3A%2018px%3B%0A%20%20%20%20text%2Ddecoration%3A%20none%3B%0A%20%20%20%20margin%2Dbottom%3A%200px%3B%0A%7D%0Abody%0A%7B%0A%20%20%20%20background%2Dcolor%3A%20%23FFFFFF%3B%0A%7D%0Atable%23page%5Fheader%0A%7B%0A%20%20%20%20width%3A%20100%25%3B%0A%20%20%20%20height%3A%2080px%3B%0A%20%20%20%20background%2Dcolor%3A%20%23FFFFFF%3B%0A%20%20%20%20background%2Drepeat%3A%20repeat%2Dx%3B%0A%7D%0Atable%23main%5Ftable%0A%7B%0A%20%20%20%20width%3A100%25%3B%0A%7D%0A%3C%2Fstyle%3E%0A%3C%2Fhead%3E%0A%0A%3Cscript%20language%3D%22javascript%22%3E%0Afunction%20OnLoad%28%29%20%7B%0A%20%20%20%20var%20category%20%3D%20%22Information%20Technology%22%3B%0A%20%20%20%20var%20categoryDiv%20%3D%20document%2EgetElementById%28%27display%5Fcategory%27%29%3B%0A%20%20%20%20if%20%28category%20%3D%3D%3D%20%22%22%29%20%7B%0A%20%20%20%20%20%20%20%20categoryDiv%2Estyle%2Evisibility%20%3D%20%27hidden%27%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20categoryDiv%2Estyle%2Evisibility%20%3D%20%27visible%27%3B%0A%20%20%20%20%20%20%20%20categoryDiv%2EinnerHTML%20%2B%3D%20%27%3Ctd%3E%27%20%2B%20%22The%20category%20reference%20is%3A%22%20%2B%20%27%20%27%20%2B%20category%20%2B%20%27%3C%2Ftd%3E%27%3B%0A%20%20%20%20%7D%0A%7D%0A%3C%2Fscript%3E%0A%3Cbody%20onload%3D%22OnLoad%28%29%3B%22%3E%0A%20%20%20%20%3Ctable%20id%3D%22page%5Fheader%22%3E%0A%20%20%20%20%20%20%20%20%3Ctr%3E%3Ctd%20style%3D%22padding%2Dleft%3A10px%3B%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Ch1%3ETransparent%20proxy%20access%20blocked%2E%20%3Cbr%3E%20Please%20verify%20your%20proxy%20setting%20are%20correct%2E%20%3Cbr%3E%20Contact%20CCHD%20if%20you%20need%20assistance%2E%3C%2Fh1%3E%20%20%20%20%20%20%20%20%3C%2Ftd%3E%3C%2Ftr%3E%0A%20%20%20%20%3C%2Ftable%3E%0A%20%20%20%20%3Ctable%20id%3D%27main%5Ftable%27%3E%0A%20%20%20%20%20%20%20%20%3Ctr%20id%3D%27display%5Fcategory%27%3E%3C%2Ftr%3E%0A%20%20%20%20%3C%2Ftable%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A" rel="icon" />
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
  
</head>
<body>
<div class="wrapper">
<header id="title-block-header">
<h1 class="title" style="text-align:center">Fix layout mappings all
static extent default constructor</h1>

<table style="border:none;float:right">
  <tr>
    <td>Document #: </td>
    <td>P2798R0</td>
  </tr>
  <tr>
    <td>Date: </td>
    <td>2023-02-07</td>
  </tr>
  <tr>
    <td style="vertical-align:top">Project: </td>
    <td>Programming Language C++<br>
      LWG<br>
    </td>
  </tr>
  <tr>
    <td style="vertical-align:top">Reply-to: </td>
    <td>
      Christian Trott<br>&lt;<a href="mailto:crtrott@sandia.gov" class="email">crtrott@sandia.gov</a>&gt;<br>
      Damien Lebrun-Grandie<br>&lt;<a href="mailto:lebrungrandt@ornl.gov" class="email">lebrungrandt@ornl.gov</a>&gt;<br>
      Mark Hoemmen<br>&lt;<a href="mailto:mhoemmen@nvidia.com" class="email">mhoemmen@nvidia.com</a>&gt;<br>
    </td>
  </tr>
</table>

</header>
<div style="clear:both">
<div id="TOC" role="doc-toc">
<h1 id="toctitle">Contents</h1>
<ul>
<li><a href="#revision-history" id="toc-revision-history"><span class="toc-section-number">1</span> Revision History</a>
<ul>
<li><a href="#initial-version-2023-02-mailing" id="toc-initial-version-2023-02-mailing"><span class="toc-section-number">1.1</span> Initial Version 2023-02
Mailing</a></li>
</ul></li>
<li><a href="#rationale" id="toc-rationale"><span class="toc-section-number">2</span> Rationale</a>
<ul>
<li><a href="#proposed-wording" id="toc-proposed-wording"><span class="toc-section-number">2.1</span> Proposed Wording</a></li>
</ul></li>
</ul>
</div>
<h1 data-number="1" id="revision-history"><span class="header-section-number">1</span> Revision History<a href="#revision-history" class="self-link"></a></h1>
<h2 data-number="1.1" id="initial-version-2023-02-mailing"><span class="header-section-number">1.1</span> Initial Version 2023-02
Mailing<a href="#initial-version-2023-02-mailing" class="self-link"></a></h2>
<h1 data-number="2" id="rationale"><span class="header-section-number">2</span> Rationale<a href="#rationale" class="self-link"></a></h1>
<p>When default constructing a <code>layout_left</code>,
<code>layout_right</code> or <code>layout_stride</code> mapping with all
static extents, there is currently no precondition check guarding
against overflow of the <code>index_type</code>.</p>
<p>A simple example is constructing the following
<code>layout_left</code> mapping:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> N <span class="op">=</span> <span class="dv">4&#39;000&#39;000</span>;</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>layout_left<span class="op">::</span>mapping<span class="op">&lt;</span>extents<span class="op">&lt;</span><span class="dt">int</span>, N, N<span class="op">&gt;&gt;</span> map;</span></code></pre></div>
<p>Each individual extent fits into <code>int</code> but the theoretical
required span size does not.</p>
<p>The non-default constructors already deal with this issue via a
preconditions such as:</p>
<p><em>Preconditions:</em> The size of the multidimensional index space
<code>e</code> is representable as a value of type
<code>index_type</code> ([basic.fundamental]).</p>
<p>For cases where at least one of the extents is dynamic, the default
constructor is also fine, since it will result in an empty index space.
That leaves only the case for all static extents to be fixed. We propose
here to add a mandate to the mapping classes of
<code>layout_left</code>, <code>layout_right</code>, and
<code>layout_stride</code> that the forward product of extents is
representable as <code>index_type</code>.</p>
<h2 data-number="2.1" id="proposed-wording"><span class="header-section-number">2.1</span> Proposed Wording<a href="#proposed-wording" class="self-link"></a></h2>
<p>In subsection 24.7.3.4.5.1 [mdspan.layout.left.overview] add after
paragraph 3:</p>
<p><em>Mandates:</em> If <code>Extents::rank_dynamic() == 0</code> is
<code>true</code>, then the size of the multidimensional index space
<code>Extents()</code> is representable as a value of type
<code>typename Extents::index_type</code>.</p>
<p>In subsection 24.7.3.4.6.1 [mdspan.layout.right.overview] add after
paragraph 3:</p>
<p><em>Mandates:</em> If <code>Extents::rank_dynamic() == 0</code> is
<code>true</code>, then the size of the multidimensional index space
<code>Extents()</code> is representable as a value of type
<code>typename Extents::index_type</code>.</p>
<p>In subsection 24.7.3.4.7.1 [mdspan.layout.stride.overview] add after
paragraph 3:</p>
<p><em>Mandates:</em> If <code>Extents::rank_dynamic() == 0</code> is
<code>true</code>, then the size of the multidimensional index space
<code>Extents()</code> is representable as a value of type
<code>typename Extents::index_type</code>.</p>
</div>
</div>
</body>
</html>
