Skip to content

Commit b2bc7e5

Browse files
mattkretztkoeppe
authored andcommitted
P2876R3 Proposal to extend std::simd with more constructors and accessors
1 parent bd2d827 commit b2bc7e5

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

source/numerics.tex

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19112,6 +19112,8 @@
1911219112
template<size_t UBytes, class UAbi>
1911319113
constexpr explicit basic_simd_mask(const basic_simd_mask<UBytes, UAbi>&) noexcept;
1911419114
template<class G> constexpr explicit basic_simd_mask(G&& gen) noexcept;
19115+
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
19116+
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;
1911519117

1911619118
// \ref{simd.mask.subscr}, \tcode{basic_simd_mask} subscript operators
1911719119
constexpr value_type operator[](@\exposid{simd-size-type}@) const;
@@ -19126,6 +19128,10 @@
1912619128
template<class U, class A>
1912719129
constexpr explicit(sizeof(U) != Bytes) operator basic_simd<U, A>() const noexcept;
1912819130

19131+
// \ref{simd.mask.namedconv}, \tcode{basic_simd_mask} named type convertors
19132+
constexpr bitset<size()> to_bitset() const noexcept;
19133+
constexpr unsigned long long to_ullong() const;
19134+
1912919135
// \ref{simd.mask.binary}, \tcode{basic_simd_mask} binary operators
1913019136
friend constexpr basic_simd_mask
1913119137
operator&&(const basic_simd_mask&, const basic_simd_mask&) noexcept;
@@ -19258,6 +19264,31 @@
1925819264
\tcode{gen} is invoked exactly once for each $i$, in increasing order of $i$.
1925919265
\end{itemdescr}
1926019266

19267+
\begin{itemdecl}
19268+
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
19269+
\end{itemdecl}
19270+
19271+
\begin{itemdescr}
19272+
\pnum
19273+
\effects
19274+
Initializes the $i^\text{th}$ element with \tcode{b[$i$]} for all $i$ in the
19275+
range \range{0}{size()}.
19276+
\end{itemdescr}
19277+
19278+
\begin{itemdecl}
19279+
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;
19280+
\end{itemdecl}
19281+
19282+
\begin{itemdescr}
19283+
\pnum
19284+
\effects
19285+
Initializes the first $M$ elements to the corresponding bit values in
19286+
\tcode{val}, where $M$ is the smaller of \tcode{size()} and the number of bits in
19287+
the value representation\iref{basic.types.general} of the type of \tcode{val}. If
19288+
$M$ is less than \tcode{size()}, the remaining elements are initialized to
19289+
zero.
19290+
\end{itemdescr}
19291+
1926119292
\rSec3[simd.mask.subscr]{\tcode{basic_simd_mask} subscript operator}
1926219293

1926319294
\begin{itemdecl}
@@ -19316,6 +19347,43 @@
1931619347
\tcode{static_cast<U>(operator[]($i$))}.
1931719348
\end{itemdescr}
1931819349

19350+
\rSec3[simd.mask.namedconv]{\tcode{basic_simd_mask} named conversion operators}
19351+
19352+
\begin{itemdecl}
19353+
constexpr bitset<size()> to_bitset() const noexcept;
19354+
\end{itemdecl}
19355+
19356+
\begin{itemdescr}
19357+
\pnum
19358+
\returns
19359+
A \tcode{bitset<size()>} object where the $i^\text{th}$ element is initialized to
19360+
\tcode{operator[]($i$)} for all $i$ in the range \range{0}{size()}.
19361+
\end{itemdescr}
19362+
19363+
\begin{itemdecl}
19364+
constexpr unsigned long long to_ullong() const;
19365+
\end{itemdecl}
19366+
19367+
\begin{itemdescr}
19368+
\pnum
19369+
Let $N$ be the width of \tcode{unsigned long long}.
19370+
19371+
\pnum
19372+
\expects
19373+
\begin{itemize}
19374+
\item \tcode{size() <= $N$} is \tcode{true}, or
19375+
\item for all $i$ in the range \range{$N$}{size()}, \tcode{operator[]($i$)} returns \tcode{false}.
19376+
\end{itemize}
19377+
19378+
\pnum
19379+
\returns
19380+
The integral value corresponding to the bits in \tcode{*this}.
19381+
19382+
\pnum
19383+
\throws
19384+
Nothing.
19385+
\end{itemdescr}
19386+
1931919387
\rSec2[simd.mask.nonmembers]{Non-member operations}
1932019388

1932119389
\rSec3[simd.mask.binary]{\tcode{basic_simd_mask} binary operators}

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@
821821
#define @\defnlibxname{cpp_lib_shared_ptr_weak_type}@ 201606L // also in \libheader{memory}
822822
#define @\defnlibxname{cpp_lib_shared_timed_mutex}@ 201402L // also in \libheader{shared_mutex}
823823
#define @\defnlibxname{cpp_lib_shift}@ 202202L // also in \libheader{algorithm}
824-
#define @\defnlibxname{cpp_lib_simd}@ 202502L // also in \libheader{simd}
824+
#define @\defnlibxname{cpp_lib_simd}@ 202506L // also in \libheader{simd}
825825
#define @\defnlibxname{cpp_lib_simd_complex}@ 202502L // also in \libheader{simd}
826826
#define @\defnlibxname{cpp_lib_smart_ptr_for_overwrite}@ 202002L // also in \libheader{memory}
827827
#define @\defnlibxname{cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader{memory}

0 commit comments

Comments
 (0)