|
1377 | 1377 | // \ref{bit.cast}, \tcode{bit_cast}
|
1378 | 1378 | template<typename To, typename From>
|
1379 | 1379 | constexpr To bit_cast(const From& from) noexcept;
|
| 1380 | + |
| 1381 | + // \ref{bit.pow.two}, integral powers of 2 |
| 1382 | + template <class T> |
| 1383 | + constexpr bool ispow2(T x) noexcept; |
| 1384 | + template <class T> |
| 1385 | + constexpr T ceil2(T x) noexcept; |
| 1386 | + template <class T> |
| 1387 | + constexpr T floor2(T x) noexcept; |
| 1388 | + template <class T> |
| 1389 | + constexpr T log2p1(T x) noexcept; |
1380 | 1390 | }
|
1381 | 1391 | \end{codeblock}
|
1382 | 1392 |
|
|
1419 | 1429 | \end{itemize}
|
1420 | 1430 | \end{itemdescr}
|
1421 | 1431 |
|
| 1432 | +\rSec2[bit.pow.two]{Integral powers of 2} |
| 1433 | + |
| 1434 | +\indexlibrary{\idxcode{ispow2}}% |
| 1435 | +\begin{itemdecl} |
| 1436 | +template <class T> |
| 1437 | + constexpr bool ispow2(T x) noexcept; |
| 1438 | +\end{itemdecl} |
| 1439 | + |
| 1440 | +\begin{itemdescr} |
| 1441 | +\pnum |
| 1442 | +\returns |
| 1443 | +\tcode{true} if \tcode{x} is an integral power of two; |
| 1444 | +\tcode{false} otherwise. |
| 1445 | + |
| 1446 | +\pnum |
| 1447 | +\remarks |
| 1448 | +This function shall not participate in overload resolution |
| 1449 | +unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1450 | +\end{itemdescr} |
| 1451 | + |
| 1452 | +\indexlibrary{\idxcode{ceil2}}% |
| 1453 | +\begin{itemdecl} |
| 1454 | +template <class T> |
| 1455 | + constexpr T ceil2(T x) noexcept; |
| 1456 | +\end{itemdecl} |
| 1457 | + |
| 1458 | +\begin{itemdescr} |
| 1459 | +\pnum |
| 1460 | +\returns |
| 1461 | +The minimal value \tcode{y} such that |
| 1462 | +\tcode{ispow2(y)} is \tcode{true} and \tcode{y >= x}; |
| 1463 | +if \tcode{y} is not representable as a value of type \tcode{T}, |
| 1464 | +the result is an unspecified value. |
| 1465 | + |
| 1466 | +\pnum |
| 1467 | +\remarks |
| 1468 | +This function shall not participate in overload resolution |
| 1469 | +unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1470 | +\end{itemdescr} |
| 1471 | + |
| 1472 | +\indexlibrary{\idxcode{floor2}}% |
| 1473 | +\begin{itemdecl} |
| 1474 | +template <class T> |
| 1475 | + constexpr T floor2(T x) noexcept; |
| 1476 | +\end{itemdecl} |
| 1477 | + |
| 1478 | +\begin{itemdescr} |
| 1479 | +\pnum |
| 1480 | +\returns |
| 1481 | +If \tcode{x == 0}, \tcode{0}; |
| 1482 | +otherwise the maximal value \tcode{y} |
| 1483 | +such that \tcode{ispow2(y)} is \tcode{true} and \tcode{y <= x}. |
| 1484 | + |
| 1485 | +\pnum |
| 1486 | +\remarks |
| 1487 | +This function shall not participate in overload resolution |
| 1488 | +unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1489 | +\end{itemdescr} |
| 1490 | + |
| 1491 | +\indexlibrary{\idxcode{log2p1}}% |
| 1492 | +\begin{itemdecl} |
| 1493 | +template <class T> |
| 1494 | + constexpr T log2p1(T x) noexcept; |
| 1495 | +\end{itemdecl} |
| 1496 | + |
| 1497 | +\begin{itemdescr} |
| 1498 | +\pnum |
| 1499 | +\returns |
| 1500 | +If \tcode{x == 0}, \tcode{0}; |
| 1501 | +otherwise one plus the base-2 logarithm of \tcode{x}, |
| 1502 | +with any fractional part discarded. |
| 1503 | + |
| 1504 | +\pnum |
| 1505 | +\remarks |
| 1506 | +This function shall not participate in overload resolution |
| 1507 | +unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1508 | +\end{itemdescr} |
| 1509 | + |
1422 | 1510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1423 | 1511 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1424 | 1512 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
0 commit comments