Skip to content

Commit d874f01

Browse files
committed
P2876R3 Proposal to extend std::simd with more constructors and accessors
1 parent ac78ae7 commit d874f01

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

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

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

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

1924619277
\begin{itemdecl}
@@ -19299,6 +19330,43 @@
1929919330
\tcode{static_cast<U>(operator[]($i$))}.
1930019331
\end{itemdescr}
1930119332

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

1930419372
\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)