Skip to content

Commit b44fb2d

Browse files
committed
P2876R3 Proposal to extend std::simd with more constructors and accessors
1 parent 5e3dd6e commit b44fb2d

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
@@ -19096,6 +19096,8 @@
1909619096
template<size_t UBytes, class UAbi>
1909719097
constexpr explicit basic_simd_mask(const basic_simd_mask<UBytes, UAbi>&) noexcept;
1909819098
template<class G> constexpr explicit basic_simd_mask(G&& gen) noexcept;
19099+
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
19100+
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;
1909919101

1910019102
// \ref{simd.mask.subscr}, \tcode{basic_simd_mask} subscript operators
1910119103
constexpr value_type operator[](@\exposid{simd-size-type}@) const;
@@ -19110,6 +19112,10 @@
1911019112
template<class U, class A>
1911119113
constexpr explicit(sizeof(U) != Bytes) operator basic_simd<U, A>() const noexcept;
1911219114

19115+
// \ref{simd.mask.namedconv}, \tcode{basic_simd_mask} named type convertors
19116+
constexpr bitset<size()> to_bitset() const noexcept;
19117+
constexpr unsigned long long to_ullong() const;
19118+
1911319119
// \ref{simd.mask.binary}, \tcode{basic_simd_mask} binary operators
1911419120
friend constexpr basic_simd_mask
1911519121
operator&&(const basic_simd_mask&, const basic_simd_mask&) noexcept;
@@ -19242,6 +19248,31 @@
1924219248
\tcode{gen} is invoked exactly once for each $i$, in increasing order of $i$.
1924319249
\end{itemdescr}
1924419250

19251+
\begin{itemdecl}
19252+
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
19253+
\end{itemdecl}
19254+
19255+
\begin{itemdescr}
19256+
\pnum
19257+
\effects
19258+
Initializes the $i^\text{th}$ element with \tcode{b[$i$]} for all $i$ in the
19259+
range \range{0}{size()}.
19260+
\end{itemdescr}
19261+
19262+
\begin{itemdecl}
19263+
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;
19264+
\end{itemdecl}
19265+
19266+
\begin{itemdescr}
19267+
\pnum
19268+
\effects
19269+
Initializes the first $M$ elements to the corresponding bit values in
19270+
\tcode{val}, where $M$ is the smaller of \tcode{size()} and the number of bits in
19271+
the value representation\iref{basic.types.general} of the type of \tcode{val}. If
19272+
$M$ is less than \tcode{size()}, the remaining elements are initialized to
19273+
zero.
19274+
\end{itemdescr}
19275+
1924519276
\rSec3[simd.mask.subscr]{\tcode{basic_simd_mask} subscript operator}
1924619277

1924719278
\begin{itemdecl}
@@ -19300,6 +19331,43 @@
1930019331
\tcode{static_cast<U>(operator[]($i$))}.
1930119332
\end{itemdescr}
1930219333

19334+
\rSec3[simd.mask.namedconv]{\tcode{basic_simd_mask} named conversion operators}
19335+
19336+
\begin{itemdecl}
19337+
constexpr bitset<size()> to_bitset() const noexcept;
19338+
\end{itemdecl}
19339+
19340+
\begin{itemdescr}
19341+
\pnum
19342+
\returns
19343+
A \tcode{bitset<size()>} object where the $i^\text{th}$ element is initialized to
19344+
\tcode{operator[]($i$)} for all $i$ in the range \range{0}{size()}.
19345+
\end{itemdescr}
19346+
19347+
\begin{itemdecl}
19348+
constexpr unsigned long long to_ullong() const;
19349+
\end{itemdecl}
19350+
19351+
\begin{itemdescr}
19352+
\pnum
19353+
Let $N$ be the width of \tcode{unsigned long long}.
19354+
19355+
\pnum
19356+
\expects
19357+
\begin{itemize}
19358+
\item \tcode{size() <= $N$} is \tcode{true}, or
19359+
\item for all $i$ in the range \range{$N$}{size()}, \tcode{operator[]($i$)} returns \tcode{false}.
19360+
\end{itemize}
19361+
19362+
\pnum
19363+
\returns
19364+
The integral value corresponding to the bits in \tcode{*this}.
19365+
19366+
\pnum
19367+
\throws
19368+
Nothing.
19369+
\end{itemdescr}
19370+
1930319371
\rSec2[simd.mask.nonmembers]{Non-member operations}
1930419372

1930519373
\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
@@ -805,7 +805,7 @@
805805
#define @\defnlibxname{cpp_lib_shared_ptr_weak_type}@ 201606L // also in \libheader{memory}
806806
#define @\defnlibxname{cpp_lib_shared_timed_mutex}@ 201402L // also in \libheader{shared_mutex}
807807
#define @\defnlibxname{cpp_lib_shift}@ 202202L // also in \libheader{algorithm}
808-
#define @\defnlibxname{cpp_lib_simd}@ 202502L // also in \libheader{simd}
808+
#define @\defnlibxname{cpp_lib_simd}@ 202506L // also in \libheader{simd}
809809
#define @\defnlibxname{cpp_lib_simd_complex}@ 202502L // also in \libheader{simd}
810810
#define @\defnlibxname{cpp_lib_smart_ptr_for_overwrite}@ 202002L // also in \libheader{memory}
811811
#define @\defnlibxname{cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader{memory}

0 commit comments

Comments
 (0)