<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 4021: mdspan::is_always_meow() should be noexcept</title>
<meta property="og:title" content="Issue 4021: mdspan::is_always_meow() should be noexcept">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4021.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
<h3 id="4021"><a href="lwg-active.html#4021">4021</a>. <code>mdspan::is_always_<i>meow</i>()</code> should be <code>noexcept</code></h3>
<p><b>Section:</b> 23.7.3.6.1 <a href="https://wg21.link/mdspan.mdspan.overview">[mdspan.mdspan.overview]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Stephan T. Lavavej <b>Opened:</b> 2023-12-07 <b>Last modified:</b> 2023-12-10</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
It can easily be proven that <code>mdspan::is_always_<i>meow</i>()</code> is preconditionless and can never throw exceptions. 
microsoft/STL has already shipped a <code>noexcept</code>-strengthened implementation, libc++ would like to (see 
<a href="https://github.com/llvm/llvm-project/pull/74254">llvm/llvm-project#74254</a>), and together we believe that the 
Standard should simply mandate <code>noexcept</code> so users can rely on this. The proof is:
</p>
<ul>
<li><p>N4964 23.7.3.6.1 <a href="https://wg21.link/mdspan.mdspan.overview">[mdspan.mdspan.overview]</a>/3:</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
<code>LayoutPolicy</code> shall meet the layout mapping policy requirements (23.7.3.4.3 <a href="https://wg21.link/mdspan.layout.policy.reqmts">[mdspan.layout.policy.reqmts]</a>) [&hellip;]
</p>
</blockquote>
</li>
<li>
<p>
23.7.3.4.3 <a href="https://wg21.link/mdspan.layout.policy.reqmts">[mdspan.layout.policy.reqmts]</a>/1: 
</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
A type <code>MP</code> meets the <i>layout mapping policy</i> requirements 
if for a type <code>E</code> that is a specialization of <code>extents</code>, <code>MP::mapping&lt;E&gt;</code> is valid and denotes 
a type <code>X</code> that meets the layout mapping requirements (23.7.3.4.2 <a href="https://wg21.link/mdspan.layout.reqmts">[mdspan.layout.reqmts]</a>) [&hellip;]
</p>
</blockquote>
</li>
<li><p>23.7.3.4.2 <a href="https://wg21.link/mdspan.layout.reqmts">[mdspan.layout.reqmts]</a>/1, /1.5, /22, /24, /26:
</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
A type <code>M</code> meets the <i>layout mapping</i> requirements if
<p/>
[&hellip;]
</p>
<ol style="list-style-type: none">
<li><p>
&mdash; the following types and expressions are well-formed and have the specified semantics.
<p/>
[&hellip;]
<p/>
<code>M::is_always_unique()</code>
<p/>
<i>Result</i>: A constant expression (7.7 <a href="https://wg21.link/expr.const">[expr.const]</a>) of type <code>bool</code>.
<p/>
[&hellip;]
<p/>
<code>M::is_always_exhaustive()</code>
<p/>
<i>Result</i>: A constant expression (7.7 <a href="https://wg21.link/expr.const">[expr.const]</a>) of type <code>bool</code>.
<p/>
[&hellip;]
<p/>
<code>M::is_always_strided()</code>
<p/>
<i>Result</i>: A constant expression (7.7 <a href="https://wg21.link/expr.const">[expr.const]</a>) of type <code>bool</code>.
</p></li>
</ol>
</blockquote>
</li>
</ul>
<p>
Constant expressions can surely be obtained without throwing exceptions.
</p>


<p id="res-4021"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4964" title=" Working Draft, Programming Languages — C++">N4964</a>.
</p>

<ol>

<li><p>Modify 23.7.3.6.1 <a href="https://wg21.link/mdspan.mdspan.overview">[mdspan.mdspan.overview]</a>, class template <code>mdspan</code> synopsis, as indicated:</p>

<blockquote>
<pre>
[&hellip;]
static constexpr bool is_always_unique() <ins>noexcept</ins>
  { return mapping_type::is_always_unique(); }
static constexpr bool is_always_exhaustive() <ins>noexcept</ins>
  { return mapping_type::is_always_exhaustive(); }
static constexpr bool is_always_strided() <ins>noexcept</ins>
  { return mapping_type::is_always_strided(); }
[&hellip;]
</pre>
</blockquote>
</li>
</ol>





</body>
</html>
