Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions source/numerics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,10 @@
template<class To, class From>
constexpr To bit_cast(const From& from) noexcept;

// \ref{bit.byteswap}, \tcode{byteswap}
template<class T>
constexpr T byteswap(T value) noexcept;

// \ref{bit.pow.two}, integral powers of 2
template<class T>
constexpr bool has_single_bit(T x) noexcept;
Expand Down Expand Up @@ -1355,6 +1359,15 @@
if there is no value of the object's type corresponding to the
value representation produced, the behavior is undefined.
If there are multiple such values, which value is produced is unspecified.
A bit in the value representation of the result is indeterminate if
it does not correspond to a bit in the value representation of \tcode{from} or
corresponds to a bit of an object that is not within its lifetime or
has an indeterminate value\iref{basic.indet}.
For each bit in the value representation of the result that is indeterminate,
the smallest object containing that bit has an indeterminate value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue with paper: Is "smallest" sufficiently clear here? The spec doesn't define size comparisons of objects afaikt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume "smallest" refers to subobject inclusion.

the behavior is undefined unless that object is
of unsigned ordinary character type or \tcode{std::byte} type.
The result does not otherwise contain any indeterminate values.

\pnum
\remarks
Expand All @@ -1370,6 +1383,34 @@
\end{itemize}
\end{itemdescr}

\rSec2[bit.byteswap]{\tcode{byteswap}}

\indexlibraryglobal{byteswap}%
\begin{itemdecl}
template<class T>
constexpr T byteswap(T value) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{T} models \libconcept{integral}.

\pnum
\mandates
\tcode{T} does not have padding bits\iref{basic.types.general}.

\pnum
Let the sequence $R$ comprise
the bytes of the object representation of \tcode{value} in reverse order.

\pnum
\returns
An object \tcode{v} of type \tcode{T}
such that each byte in the object representation of \tcode{v} is equal to
the byte in the corresponding position in $R$.
\end{itemdescr}

\rSec2[bit.pow.two]{Integral powers of 2}

\indexlibraryglobal{has_single_bit}%
Expand Down
1 change: 1 addition & 0 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@
#define @\defnlibxname{cpp_lib_bounded_array_traits}@ 201902L // also in \libheader{type_traits}
#define @\defnlibxname{cpp_lib_boyer_moore_searcher}@ 201603L // also in \libheader{functional}
#define @\defnlibxname{cpp_lib_byte}@ 201603L // also in \libheader{cstddef}
#define @\defnlibxname{cpp_lib_byteswap}@ 202110L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_char8_t}@ 201907L
// also in \libheader{atomic}, \libheader{filesystem}, \libheader{istream}, \libheader{limits}, \libheader{locale}, \libheader{ostream}, \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono}
Expand Down