From 05ea56bf8d7301a3b36fb9fd30387e014c7247f8 Mon Sep 17 00:00:00 2001 From: Eisenwave Date: Sun, 5 Apr 2026 18:00:44 +0200 Subject: [PATCH] P3932R0 Fix LWG4470: Fix integer-from in [simd] --- source/numerics.tex | 138 ++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 64 deletions(-) diff --git a/source/numerics.tex b/source/numerics.tex index 31a2e217d6..12caf5e18c 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -16542,6 +16542,8 @@ template constexpr @\exposidnc{simd-size-type} \exposidnc{simd-size-v} = \seebelownc@; // \expos +template + constexpr @\exposidnc{simd-size-type} \exposidnc{mask-size-v} = \seebelownc@; // \expos template constexpr size_t @\exposidnc{mask-element-size} = \seebelownc@; // \expos template @@ -16640,6 +16642,19 @@ otherwise. \end{itemdescr} +\begin{itemdecl} +template + constexpr @\exposid{simd-size-type} \exposid{mask-size-v}@ = @\seebelow@; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\tcode{\exposid{mask-size-v}} denotes +the width of \tcode{basic_mask} +if the specialization \tcode{basic_mask} is enabled, or +\tcode{0} otherwise. +\end{itemdescr} + \begin{itemdecl} template constexpr size_t @\exposid{mask-element-size}@ = @\seebelow@; \end{itemdecl} @@ -16781,26 +16796,26 @@ An implementation defines ABI tag types as necessary for the following aliases. \pnum -\tcode{\exposid{deduce-abi-t}} is defined if +\tcode{\exposid{deduce-abi-t}} names an ABI tag type if and only if \begin{itemize} \item \tcode{T} is a vectorizable type, \item \tcode{N} is greater than zero, and \item \tcode{N} is not larger than an implementation-defined maximum. \end{itemize} +Otherwise, \tcode{\exposid{deduce-abi-t}} names an unspecified type. The \impldef{maximum width for \tcode{vec} and \tcode{mask}} maximum for \tcode{N} is not smaller than 64 and can differ depending on \tcode{T}. \pnum -Where present, \tcode{\exposid{deduce-abi-t}} names an ABI tag type such -that +If \tcode{\exposid{deduce-abi-t}} names an ABI tag type, +the following is \tcode{true}: \begin{itemize} - \item - \tcode{\exposid{simd-size-v}>} equals - \tcode{N}, \item \tcode{basic_vec>} is - enabled\iref{simd.overview}, and - \item - \tcode{basic_mask, N>>} is enabled. +\item + \tcode{\exposid{simd-size-v}>} + equals \tcode{N}, and +\item + \tcode{basic_vec>} + is enabled\iref{simd.overview}. \end{itemize} \pnum @@ -17043,12 +17058,11 @@ constexpr auto chunk(const basic_mask& x) noexcept; template - constexpr basic_vec::size() + ...)>> - cat(const basic_vec&...) noexcept; + constexpr resize_t<(basic_vec::size() + ...), + basic_vec> cat(const basic_vec&...) noexcept; template - constexpr basic_mask, - (basic_mask::size() + ...)>> - cat(const basic_mask&...) noexcept; + constexpr resize_t<(basic_mask::size() + ...)>, + basic_mask> cat(const basic_mask&...) noexcept; // \ref{simd.alg}, algorithms template @@ -17318,9 +17332,9 @@ template<@\exposconcept{simd-complex}@ V> constexpr V pow(const V& x, const V& y); // \ref{simd.mask.class}, class template \tcode{basic_mask} - template>> class basic_mask; + template class basic_mask; template>> - using @\libmember{mask}{simd}@ = basic_mask>; + using @\libmember{mask}{simd}@ = vec::mask_type; // \ref{simd.mask.reductions}, reductions template @@ -17508,8 +17522,7 @@ \begin{itemize} \item \tcode{V} is a data-parallel type, \item \tcode{T} is a vectorizable type, and -\item \tcode{\exposid{deduce-abi-t}} has a member type - \tcode{type}. +\item \tcode{\exposid{deduce-abi-t}} names an ABI tag type. \end{itemize} \pnum @@ -17534,34 +17547,33 @@ \begin{itemdescr} \pnum -Let \tcode{T} denote +Let \tcode{Abi1} denote an ABI tag \begin{itemize} \item - \tcode{typename V::value_type} if \tcode{V} is a specialization of - \tcode{basic_vec}, + such that \tcode{\exposid{simd-size-v}} + equals \tcode{N} if \tcode{V} is a specialization of \tcode{basic_vec}, \item - otherwise \tcode{\exposid{integer-from}<\exposid{mask-element-size}>} if - \tcode{V} is a specialization of \tcode{basic_mask}. + otherwise such that + \tcode{\exposid{mask-size-v}<\exposid{mask-element-size}, Abi1>} + equals \tcode{N} if \tcode{V} is a specialization of \tcode{basic_mask}. \end{itemize} \pnum The member \tcode{type} is present if and only if \begin{itemize} -\item \tcode{V} is a data-parallel type, and -\item \tcode{\exposid{deduce-abi-t}} has a member type \tcode{type}. +\item + \tcode{V} is a data-parallel type, and +\item + there exists at least one ABI tag + that satisfies the above constraints for \tcode{Abi1}. \end{itemize} \pnum -If \tcode V is a specialization of \tcode{basic_vec}, let \tcode{Abi1} denote an -ABI tag such that \tcode{basic_vec::\brk{}size()} equals \tcode{N}. -If \tcode V is a specialization of \tcode{basic_mask}, let \tcode{Abi1} -denote an ABI tag such that \tcode{basic_mask::size()} equals \tcode{N}. - -\pnum -Where present, the member typedef \tcode{type} names \tcode{basic_vec} -if \tcode V is a specialization of \tcode{basic_vec} or -\tcode{basic_mask} if \tcode V is a specialization of -\tcode{basic_mask}. +Where present, the member typedef \tcode{type} names +\tcode{basic_vec} +if \tcode{V} is a specialization of \tcode{basic_vec}, or +\tcode{basic_mask<\exposid{mask-element-size}, Abi1>} +if \tcode{V} is a specialization of \tcode{basic_mask}. \end{itemdescr} \rSec2[simd.flags]{Load and store flags} @@ -17986,7 +17998,8 @@ \begin{itemize} \item enabled, if \tcode{T} is a vectorizable type, and there exists value - \tcode{N} in the range \crange{1}{64}, such that \tcode{Abi} is + \tcode{N} in the range \crange{1}{64}, + such that \tcode{Abi} names the ABI tag denoted by \tcode{\exposid{deduce-abi-t}}, \item otherwise, disabled, if \tcode{T} is not a vectorizable type, @@ -18001,10 +18014,22 @@ In addition only the \tcode{value_type}, \tcode{abi_type}, and \tcode{mask_type} members are present. -If \tcode{basic_vec} is enabled, then \tcode{basic_vec} is -trivially copyable, default-initialization of an object of such a type -default-initializes all elements, and value-initialization value-initializes -all elements\iref{dcl.init.general}. +If \tcode{basic_vec} is enabled, then +\begin{itemize} +\item + \tcode{basic_vec} is trivially copyable, +\item + default-initialization of an object of such a type + default-initializes all elements, +\item + value-initialization value-initializes all elements\iref{dcl.init.general}, +\item + \tcode{basic_vec::mask_type} is an alias + for an enabled specialization of \tcode{basic_mask}, and +\item + \tcode{basic_vec::size()} is equal to + \tcode{basic_vec::mask_type::size()}. +\end{itemize} \pnum \recommended @@ -19550,28 +19575,14 @@ \indexlibrarymember{cat}{simd} \begin{itemdecl} template - constexpr vec::size() + ...)> - cat(const basic_vec&... xs) noexcept; + constexpr resize_t<(basic_vec::size() + ...), + basic_vec> cat(const basic_vec&... xs) noexcept; template - constexpr basic_mask, - (basic_mask::size() + ...)>> - cat(const basic_mask&... xs) noexcept; + constexpr resize_t<(basic_mask::size() + ...), + basic_mask> cat(const basic_mask&... xs) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum -\constraints -\begin{itemize} - \item - For the first overload \tcode{vec::size() + ...)>} - is enabled. - \item - For the second overload - \tcode{basic_mask, - (basic_mask::size() + ...)>>} is enabled. -\end{itemize} - \pnum \returns A data-parallel object initialized with the concatenated values in the @@ -20385,8 +20396,7 @@ constexpr default_sentinel_t @\libmember{end}{basic_mask}@() const noexcept { return {}; } constexpr default_sentinel_t @\libmember{cend}{basic_mask}@() const noexcept { return {}; } - static constexpr integral_constant<@\exposid{simd-size-type}@, @\exposid{simd-size-v}@<@\exposid{integer-from}@, Abi>> - @\libmember{size}{basic_mask}@ {}; + static constexpr integral_constant<@\exposid{simd-size-type}@, @\exposid{mask-size-v}@> @\libmember{size}{basic_mask}@ {}; constexpr basic_mask() noexcept = default; @@ -20474,9 +20484,9 @@ is equal to \tcode{sizeof(T)}, \item otherwise, enabled, if there exists a vectorizable type \tcode{T} and a - value \tcode{N} in the range \crange{1}{64} such that \tcode{Bytes} is equal - to \tcode{sizeof(T)} and \tcode{Abi} is \tcode{\exposid{deduce-abi-t}}, + value \tcode{N} in the range \crange{1}{64} + such that \tcode{Bytes} is equal to \tcode{sizeof(T)} and + \tcode{Abi} names the ABI tag denoted by \tcode{\exposid{decude-abi-t}}, \item otherwise, it is \impldef{set of enabled \tcode{basic_mask} specializations} if such a specialization is enabled.