|
1290 | 1290 | template<class To, class From>
|
1291 | 1291 | constexpr To bit_cast(const From& from) noexcept;
|
1292 | 1292 |
|
| 1293 | + // \ref{bit.byteswap}, \tcode{byteswap} |
| 1294 | + template<class T> |
| 1295 | + constexpr T byteswap(T value) noexcept; |
| 1296 | + |
1293 | 1297 | // \ref{bit.pow.two}, integral powers of 2
|
1294 | 1298 | template<class T>
|
1295 | 1299 | constexpr bool has_single_bit(T x) noexcept;
|
|
1355 | 1359 | if there is no value of the object's type corresponding to the
|
1356 | 1360 | value representation produced, the behavior is undefined.
|
1357 | 1361 | If there are multiple such values, which value is produced is unspecified.
|
| 1362 | +A bit in the value representation of the result is indeterminate if |
| 1363 | +it does not correspond to a bit in the value representation of \tcode{from} or |
| 1364 | +corresponds to a bit of an object that is not within its lifetime or |
| 1365 | +has an indeterminate value\iref{basic.indet}. |
| 1366 | +For each bit in the value representation of the result that is indeterminate, |
| 1367 | +the smallest object containing that bit has an indeterminate value; |
| 1368 | +the behavior is undefined unless that object is |
| 1369 | +of unsigned ordinary character type or \tcode{std::byte} type. |
| 1370 | +The result does not otherwise contain any indeterminate values. |
1358 | 1371 |
|
1359 | 1372 | \pnum
|
1360 | 1373 | \remarks
|
|
1370 | 1383 | \end{itemize}
|
1371 | 1384 | \end{itemdescr}
|
1372 | 1385 |
|
| 1386 | +\rSec2[bit.byteswap]{\tcode{byteswap}} |
| 1387 | + |
| 1388 | +\indexlibraryglobal{byteswap}% |
| 1389 | +\begin{itemdecl} |
| 1390 | +template<class T> |
| 1391 | + constexpr T byteswap(T value) noexcept; |
| 1392 | +\end{itemdecl} |
| 1393 | + |
| 1394 | +\begin{itemdescr} |
| 1395 | +\pnum |
| 1396 | +\constraints |
| 1397 | +\tcode{T} models \libconcept{integral}. |
| 1398 | + |
| 1399 | +\pnum |
| 1400 | +\mandates |
| 1401 | +\tcode{T} does not have padding bits\iref{basic.types.general}. |
| 1402 | + |
| 1403 | +\pnum |
| 1404 | +Let the sequence $R$ comprise |
| 1405 | +the bytes of the object representation of \tcode{value} in reverse order. |
| 1406 | + |
| 1407 | +\pnum |
| 1408 | +\returns |
| 1409 | +An object \tcode{v} of type \tcode{T} |
| 1410 | +such that each byte in the object representation of \tcode{v} is equal to |
| 1411 | +the byte in the corresponding position in $R$. |
| 1412 | +\end{itemdescr} |
| 1413 | + |
1373 | 1414 | \rSec2[bit.pow.two]{Integral powers of 2}
|
1374 | 1415 |
|
1375 | 1416 | \indexlibraryglobal{has_single_bit}%
|
|
0 commit comments