|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4403" status="New"> |
| 5 | +<title>`simd::basic_vec` CTAD misses difference type casting</title> |
| 6 | +<section> |
| 7 | +<sref ref="[simd.ctor]"/> |
| 8 | +</section> |
| 9 | +<submitter>Hewill Kang</submitter> |
| 10 | +<date>04 Oct 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +Currently, `basic_vec` can take an object `r` of range type `R` whose size is a |
| 16 | +constant expression and deduced to <code>vec<ranges::range_value_t<R>, ranges::size(r)></code>. |
| 17 | +<p/> |
| 18 | +However, such a deduced type is ill-formed when `R` has a an integer-class type size which cannot |
| 19 | +be implicitly converted to <code><i>simd-size-type</i></code>, which is a signed integer type. |
| 20 | +<p/> |
| 21 | +It is necessary to perform difference type casting here, and the narrowing |
| 22 | +conversion will still correctly be rejected due to the constructor's constraints. |
| 23 | +</p> |
| 24 | +</discussion> |
| 25 | + |
| 26 | +<resolution> |
| 27 | +<p> |
| 28 | +This wording is relative to <paper num="N5014"/>. |
| 29 | +</p> |
| 30 | + |
| 31 | +<ol> |
| 32 | + |
| 33 | +<li><p>Modify <sref ref="[simd.ctor]"/> as indicated:</p> |
| 34 | + |
| 35 | +<blockquote> |
| 36 | +<pre> |
| 37 | +template<class R, class... Ts> |
| 38 | + basic_vec(R&& r, Ts...) -> <i>see below</i>; |
| 39 | +</pre> |
| 40 | +<blockquote> |
| 41 | +<p> |
| 42 | +-17- <i>Constraints</i>: |
| 43 | +</p> |
| 44 | +<ol style="list-style-type: none"> |
| 45 | + <li><p> |
| 46 | + (17.1) — `R` models `ranges::contiguous_range` and `ranges::sized_range`, and |
| 47 | + </p></li> |
| 48 | + <li><p> |
| 49 | + (17.2) — `ranges::size(r)` is a constant expression. |
| 50 | + </p></li> |
| 51 | +</ol> |
| 52 | +<p> |
| 53 | +-18- <i>Remarks</i>: The deduced type is equivalent to <code> |
| 54 | +vec<ranges::range_value_t<R>, <ins>static_cast<<i>simd-size-type</i>>(</ins>ranges::size(r)<ins>)</ins>> |
| 55 | +</code> |
| 56 | +</p> |
| 57 | +</blockquote> |
| 58 | +</blockquote> |
| 59 | +</li> |
| 60 | + |
| 61 | +</ol> |
| 62 | + |
| 63 | +</resolution> |
| 64 | + |
| 65 | +</issue> |
0 commit comments