|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4272: For rank == 0, layout_stride is atypically convertible</title> |
| 6 | +<meta property="og:title" content="Issue 4272: For rank == 0, layout_stride is atypically convertible"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4272.html"> |
| 9 | +<meta property="og:type" content="website"> |
| 10 | +<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png"> |
| 11 | +<meta property="og:image:alt" content="C++ logo"> |
| 12 | +<style> |
| 13 | + p {text-align:justify} |
| 14 | + li {text-align:justify} |
| 15 | + pre code.backtick::before { content: "`" } |
| 16 | + pre code.backtick::after { content: "`" } |
| 17 | + blockquote.note |
| 18 | + { |
| 19 | + background-color:#E0E0E0; |
| 20 | + padding-left: 15px; |
| 21 | + padding-right: 15px; |
| 22 | + padding-top: 1px; |
| 23 | + padding-bottom: 1px; |
| 24 | + } |
| 25 | + ins {background-color:#A0FFA0} |
| 26 | + del {background-color:#FFA0A0} |
| 27 | + table.issues-index { border: 1px solid; border-collapse: collapse; } |
| 28 | + table.issues-index th { text-align: center; padding: 4px; border: 1px solid; } |
| 29 | + table.issues-index td { padding: 4px; border: 1px solid; } |
| 30 | + table.issues-index td:nth-child(1) { text-align: right; } |
| 31 | + table.issues-index td:nth-child(2) { text-align: left; } |
| 32 | + table.issues-index td:nth-child(3) { text-align: left; } |
| 33 | + table.issues-index td:nth-child(4) { text-align: left; } |
| 34 | + table.issues-index td:nth-child(5) { text-align: center; } |
| 35 | + table.issues-index td:nth-child(6) { text-align: center; } |
| 36 | + table.issues-index td:nth-child(7) { text-align: left; } |
| 37 | + table.issues-index td:nth-child(5) span.no-pr { color: red; } |
| 38 | + @media (prefers-color-scheme: dark) { |
| 39 | + html { |
| 40 | + color: #ddd; |
| 41 | + background-color: black; |
| 42 | + } |
| 43 | + ins { |
| 44 | + background-color: #225522 |
| 45 | + } |
| 46 | + del { |
| 47 | + background-color: #662222 |
| 48 | + } |
| 49 | + a { |
| 50 | + color: #6af |
| 51 | + } |
| 52 | + a:visited { |
| 53 | + color: #6af |
| 54 | + } |
| 55 | + blockquote.note |
| 56 | + { |
| 57 | + background-color: rgba(255, 255, 255, .10) |
| 58 | + } |
| 59 | + } |
| 60 | +</style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<hr> |
| 64 | +<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> |
| 65 | +<h3 id="4272"><a href="lwg-active.html#4272">4272</a>. For <code class='backtick'>rank == 0</code>, <code class='backtick'>layout_stride</code> is atypically convertible</h3> |
| 66 | +<p><b>Section:</b> 23.7.3.4 <a href="https://wg21.link/mdspan.layout">[mdspan.layout]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Luc Grosheintz <b>Opened:</b> 2025-06-02 <b>Last modified:</b> 2025-06-06</p> |
| 68 | +<p><b>Priority: </b>Not Prioritized |
| 69 | +</p> |
| 70 | +<p><b>View all other</b> <a href="lwg-index.html#mdspan.layout">issues</a> in [mdspan.layout].</p> |
| 71 | +<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
| 72 | +<p><b>Discussion:</b></p> |
| 73 | +<p> |
| 74 | +Commonly, two layouts are considered convertible, if the underlying |
| 75 | +<code class='backtick'>extent_types</code> are convertible. |
| 76 | +<p/> |
| 77 | +However, for the two ctors <code class='backtick'>layout_left(layout_stride)</code> and |
| 78 | +<code class='backtick'>layout_right(layout_stride)</code>, the condition is <code>rank > 0</code>. Therefore, |
| 79 | +</p> |
| 80 | +<blockquote><pre> |
| 81 | +using E1 = std::extents<int>; |
| 82 | +using E2 = std::extents<unsigned int>; |
| 83 | + |
| 84 | +static_assert(std::is_convertible_v< |
| 85 | + std::layout_stride::mapping<E2>, |
| 86 | + std::layout_right::mapping<E1> |
| 87 | + >); |
| 88 | +</pre></blockquote> |
| 89 | +<p> |
| 90 | +even though: |
| 91 | +</p> |
| 92 | +<blockquote><pre> |
| 93 | +static_assert(!std::is_convertible_v<E2, E1>); |
| 94 | +</pre></blockquote> |
| 95 | +<p> |
| 96 | +Moreover, for rank 0 <code class='backtick'>layout_stride</code> can be converted to any |
| 97 | +specialization of <code class='backtick'>layout_left</code> or <code class='backtick'>layout_right</code>; but not to every |
| 98 | +specialization of <code class='backtick'>layout_stride</code>. |
| 99 | +</p> |
| 100 | + |
| 101 | + |
| 102 | +<p id="res-4272"><b>Proposed resolution:</b></p> |
| 103 | +<p> |
| 104 | +This wording is relative to <a href="https://wg21.link/N5008">N5008</a>. |
| 105 | +</p> |
| 106 | + |
| 107 | +<blockquote class="note"> |
| 108 | +<p> |
| 109 | +[<i>Drafting note</i>: As drive-by fixes the edits for <code>layout_left_padded<>::mapping</code> and |
| 110 | +<code>layout_right_padded<>::mapping</code> also correct an editorial asymmetry between class |
| 111 | +header synopsis declaration form and prototype specification form of the corresponding |
| 112 | +constructors and adjust to the correct spelling of the exposition-only data member <code><i>rank_</i></code>.] |
| 113 | +</p> |
| 114 | +</blockquote> |
| 115 | + |
| 116 | +<ol> |
| 117 | +<li><p>Modify 23.7.3.4.5.1 <a href="https://wg21.link/mdspan.layout.left.overview">[mdspan.layout.left.overview]</a> as indicated:</p> |
| 118 | + |
| 119 | +<blockquote> |
| 120 | +<pre> |
| 121 | +namespace std { |
| 122 | + template<class Extents> |
| 123 | + class layout_left::mapping { |
| 124 | + […] |
| 125 | + <i>// 23.7.3.4.5.2 <a href="https://wg21.link/mdspan.layout.left.cons">[mdspan.layout.left.cons]</a>, constructors</i> |
| 126 | + […] |
| 127 | + template<class OtherExtents> |
| 128 | + constexpr explicit(<del>extents_type::rank() > 0</del><ins><i>see below</i></ins>) |
| 129 | + mapping(const layout_stride::mapping<OtherExtents>&); |
| 130 | + |
| 131 | + constexpr mapping& operator=(const mapping&) noexcept = default; |
| 132 | + […] |
| 133 | + }; |
| 134 | +} |
| 135 | +</pre> |
| 136 | +</blockquote> |
| 137 | +</li> |
| 138 | + |
| 139 | +<li><p>Modify 23.7.3.4.5.2 <a href="https://wg21.link/mdspan.layout.left.cons">[mdspan.layout.left.cons]</a> as indicated:</p> |
| 140 | + |
| 141 | +<blockquote> |
| 142 | +<pre> |
| 143 | +template<class OtherExtents> |
| 144 | + constexpr explicit(<del>extents_type::rank() > 0</del><ins><i>see below</i></ins>) |
| 145 | + mapping(const layout_stride::mapping<OtherExtents>& other); |
| 146 | +</pre> |
| 147 | +<blockquote> |
| 148 | +<p> |
| 149 | +-13- <i>Constraints</i>: […] |
| 150 | +<p/> |
| 151 | +-14- <i>Preconditions</i>: […] |
| 152 | +<p/> |
| 153 | +-15- <i>Effects</i>: […] |
| 154 | +<p/> |
| 155 | +<ins>-?- <i>Remarks</i>: The expression inside <code class='backtick'>explicit</code> is equivalent to:</ins> |
| 156 | +</p> |
| 157 | +<blockquote><pre> |
| 158 | +<ins>!(extents_type::rank() == 0 && is_convertible_v<OtherExtents, extents_type>)</ins> |
| 159 | +</pre></blockquote> |
| 160 | +</blockquote> |
| 161 | +</blockquote> |
| 162 | +</li> |
| 163 | + |
| 164 | +<li><p>Modify 23.7.3.4.6.1 <a href="https://wg21.link/mdspan.layout.right.overview">[mdspan.layout.right.overview]</a> as indicated:</p> |
| 165 | + |
| 166 | +<blockquote> |
| 167 | +<pre> |
| 168 | +namespace std { |
| 169 | + template<class Extents> |
| 170 | + class layout_right::mapping { |
| 171 | + […] |
| 172 | + <i>// 23.7.3.4.6.2 <a href="https://wg21.link/mdspan.layout.right.cons">[mdspan.layout.right.cons]</a>, constructors</i> |
| 173 | + […] |
| 174 | + template<class OtherExtents> |
| 175 | + constexpr explicit(<del>extents_type::rank() > 0</del><ins><i>see below</i></ins>) |
| 176 | + mapping(const layout_stride::mapping<OtherExtents>&); |
| 177 | + |
| 178 | + constexpr mapping& operator=(const mapping&) noexcept = default; |
| 179 | + […] |
| 180 | + }; |
| 181 | +} |
| 182 | +</pre> |
| 183 | +</blockquote> |
| 184 | +</li> |
| 185 | + |
| 186 | +<li><p>Modify 23.7.3.4.6.2 <a href="https://wg21.link/mdspan.layout.right.cons">[mdspan.layout.right.cons]</a> as indicated:</p> |
| 187 | + |
| 188 | +<blockquote> |
| 189 | +<pre> |
| 190 | +template<class OtherExtents> |
| 191 | + constexpr explicit(<del>extents_type::rank() > 0</del><ins><i>see below</i></ins>) |
| 192 | + mapping(const layout_stride::mapping<OtherExtents>& other); |
| 193 | +</pre> |
| 194 | +<blockquote> |
| 195 | +<p> |
| 196 | +-13- <i>Constraints</i>: […] |
| 197 | +<p/> |
| 198 | +-14- <i>Preconditions</i>: […] |
| 199 | +<p/> |
| 200 | +-15- <i>Effects</i>: […] |
| 201 | +<p/> |
| 202 | +<ins>-?- <i>Remarks</i>: The expression inside <code class='backtick'>explicit</code> is equivalent to:</ins> |
| 203 | +</p> |
| 204 | +<blockquote><pre> |
| 205 | +<ins>!(extents_type::rank() == 0 && is_convertible_v<OtherExtents, extents_type>)</ins> |
| 206 | +</pre></blockquote> |
| 207 | +</blockquote> |
| 208 | +</blockquote> |
| 209 | +</li> |
| 210 | + |
| 211 | +<li><p>Modify 23.7.3.4.8.1 <a href="https://wg21.link/mdspan.layout.leftpad.overview">[mdspan.layout.leftpad.overview]</a> as indicated:</p> |
| 212 | + |
| 213 | +<blockquote> |
| 214 | +<pre> |
| 215 | +namespace std { |
| 216 | + template<size_t PaddingValue> |
| 217 | + template<class Extents> |
| 218 | + class layout_left_padded<PaddingValue>::mapping { |
| 219 | + […] |
| 220 | + <i>// 23.7.3.4.8.3 <a href="https://wg21.link/mdspan.layout.leftpad.cons">[mdspan.layout.leftpad.cons]</a>, constructors</i> |
| 221 | + […] |
| 222 | + template<class OtherExtents> |
| 223 | + constexpr explicit(<del>extents_type::rank() > 0</del><ins><i>see below</i></ins>) |
| 224 | + mapping(const layout_stride::mapping<OtherExtents>&); |
| 225 | + […] |
| 226 | + }; |
| 227 | +} |
| 228 | +</pre> |
| 229 | +</blockquote> |
| 230 | +</li> |
| 231 | + |
| 232 | +<li><p>Modify 23.7.3.4.8.3 <a href="https://wg21.link/mdspan.layout.leftpad.cons">[mdspan.layout.leftpad.cons]</a> as indicated:</p> |
| 233 | + |
| 234 | +<blockquote> |
| 235 | +<pre> |
| 236 | +template<class OtherExtents> |
| 237 | + constexpr explicit(<del>rank_ > 0</del><ins><i>see below</i></ins>) |
| 238 | + mapping(const layout_stride::mapping<OtherExtents>& other); |
| 239 | +</pre> |
| 240 | +<blockquote> |
| 241 | +<p> |
| 242 | +-10- <i>Constraints</i>: […] |
| 243 | +<p/> |
| 244 | +-11- <i>Preconditions</i>: […] |
| 245 | +<p/> |
| 246 | +-12- <i>Effects</i>: […] |
| 247 | +<p/> |
| 248 | +<ins>-?- <i>Remarks</i>: The expression inside <code class='backtick'>explicit</code> is equivalent to:</ins> |
| 249 | +</p> |
| 250 | +<blockquote><pre> |
| 251 | +<ins>!(<i>rank_</i> == 0 && is_convertible_v<OtherExtents, extents_type>)</ins> |
| 252 | +</pre></blockquote> |
| 253 | +</blockquote> |
| 254 | +</blockquote> |
| 255 | +</li> |
| 256 | + |
| 257 | +<li><p>Modify 23.7.3.4.9.1 <a href="https://wg21.link/mdspan.layout.rightpad.overview">[mdspan.layout.rightpad.overview]</a> as indicated:</p> |
| 258 | + |
| 259 | +<blockquote> |
| 260 | +<pre> |
| 261 | +namespace std { |
| 262 | + template<size_t PaddingValue> |
| 263 | + template<class Extents> |
| 264 | + class layout_right_padded<PaddingValue>::mapping { |
| 265 | + […] |
| 266 | + <i>// 23.7.3.4.9.3 <a href="https://wg21.link/mdspan.layout.rightpad.cons">[mdspan.layout.rightpad.cons]</a>, constructors</i> |
| 267 | + […] |
| 268 | + template<class OtherExtents> |
| 269 | + constexpr explicit(<del>rank_ > 0</del><ins><i>see below</i></ins>) |
| 270 | + mapping(const layout_stride::mapping<OtherExtents>&); |
| 271 | + […] |
| 272 | + }; |
| 273 | +} |
| 274 | +</pre> |
| 275 | +</blockquote> |
| 276 | +</li> |
| 277 | + |
| 278 | +<li><p>Modify 23.7.3.4.9.3 <a href="https://wg21.link/mdspan.layout.rightpad.cons">[mdspan.layout.rightpad.cons]</a> as indicated:</p> |
| 279 | + |
| 280 | +<blockquote> |
| 281 | +<pre> |
| 282 | +template<class OtherExtents> |
| 283 | + constexpr explicit(<del>rank_ > 0</del><ins><i>see below</i></ins>) |
| 284 | + mapping(const layout_stride::mapping<OtherExtents>& other); |
| 285 | +</pre> |
| 286 | +<blockquote> |
| 287 | +<p> |
| 288 | +-10- <i>Constraints</i>: […] |
| 289 | +<p/> |
| 290 | +-11- <i>Preconditions</i>: […] |
| 291 | +<p/> |
| 292 | +-12- <i>Effects</i>: […] |
| 293 | +<p/> |
| 294 | +<ins>-?- <i>Remarks</i>: The expression inside <code class='backtick'>explicit</code> is equivalent to:</ins> |
| 295 | +</p> |
| 296 | +<blockquote><pre> |
| 297 | +<ins>!(<i>rank_</i> == 0 && is_convertible_v<OtherExtents, extents_type>)</ins> |
| 298 | +</pre></blockquote> |
| 299 | +</blockquote> |
| 300 | +</blockquote> |
| 301 | +</li> |
| 302 | + |
| 303 | +</ol> |
| 304 | + |
| 305 | + |
| 306 | + |
| 307 | + |
| 308 | + |
| 309 | +</body> |
| 310 | +</html> |
0 commit comments