|
1317 | 1317 | constexpr T floor2(T x) noexcept;
|
1318 | 1318 | template<class T>
|
1319 | 1319 | constexpr T log2p1(T x) noexcept;
|
| 1320 | + |
| 1321 | + // \ref{bit.rotate}, rotating |
| 1322 | + template<class T> |
| 1323 | + [[nodiscard]] constexpr T rotl(T x, int s) noexcept; |
| 1324 | + template<class T> |
| 1325 | + [[nodiscard]] constexpr T rotr(T x, int s) noexcept; |
| 1326 | + |
| 1327 | + // \ref{bit.count}, counting |
| 1328 | + template<class T> |
| 1329 | + constexpr int countl_zero(T x) noexcept; |
| 1330 | + template<class T> |
| 1331 | + constexpr int countl_one(T x) noexcept; |
| 1332 | + template<class T> |
| 1333 | + constexpr int countr_zero(T x) noexcept; |
| 1334 | + template<class T> |
| 1335 | + constexpr int countr_one(T x) noexcept; |
| 1336 | + template<class T> |
| 1337 | + constexpr int popcount(T x) noexcept; |
1320 | 1338 | }
|
1321 | 1339 | \end{codeblock}
|
1322 | 1340 |
|
|
1450 | 1468 | unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}.
|
1451 | 1469 | \end{itemdescr}
|
1452 | 1470 |
|
| 1471 | +\rSec2[bit.rotate]{Rotating} |
| 1472 | + |
| 1473 | +In the following descriptions, |
| 1474 | +let \tcode{N} denote \tcode{numeric_limits<T>::digits}. |
| 1475 | + |
| 1476 | +\begin{itemdecl} |
| 1477 | +template<class T> |
| 1478 | + [[nodiscard]] constexpr T rotl(T x, int s) noexcept; |
| 1479 | +\end{itemdecl} |
| 1480 | + |
| 1481 | +\indexlibrary{\idxcode{rotl}}% |
| 1482 | +\begin{itemdescr} |
| 1483 | +\pnum |
| 1484 | +\constraints |
| 1485 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1486 | + |
| 1487 | +\pnum |
| 1488 | +Let \tcode{r} be \tcode{s \% N}. |
| 1489 | + |
| 1490 | +\pnum |
| 1491 | +\returns |
| 1492 | +If \tcode{r} is \tcode{0}, \tcode{x}; |
| 1493 | +if \tcode{r} is positive, \tcode{(x << r) | (x >> (N - r))}; |
| 1494 | +if \tcode{r} is negative, \tcode{rotr(x, -r)}. |
| 1495 | +\end{itemdescr} |
| 1496 | + |
| 1497 | +\begin{itemdecl} |
| 1498 | +template<class T> |
| 1499 | + [[nodiscard]] constexpr T rotr(T x, int s) noexcept; |
| 1500 | +\end{itemdecl} |
| 1501 | + |
| 1502 | +\indexlibrary{\idxcode{rotr}}% |
| 1503 | +\begin{itemdescr} |
| 1504 | +\pnum |
| 1505 | +\constraints |
| 1506 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1507 | + |
| 1508 | +\pnum |
| 1509 | +Let \tcode{r} be \tcode{s \% N}. |
| 1510 | + |
| 1511 | +\pnum |
| 1512 | +\returns |
| 1513 | +If \tcode{r} is \tcode{0}, \tcode{x}; |
| 1514 | +if \tcode{r} is positive, \tcode{(x >> r) | (x << (N - r))}; |
| 1515 | +if \tcode{r} is negative, \tcode{rotl(x, -r)}. |
| 1516 | +\end{itemdescr} |
| 1517 | + |
| 1518 | +\rSec2[bit.count]{Counting} |
| 1519 | + |
| 1520 | +In the following descriptions, |
| 1521 | +let \tcode{N} denote \tcode{numeric_limits<T>::digits}. |
| 1522 | + |
| 1523 | +\begin{itemdecl} |
| 1524 | +template<class T> |
| 1525 | + constexpr int countl_zero(T x) noexcept; |
| 1526 | +\end{itemdecl} |
| 1527 | + |
| 1528 | +\indexlibrary{\idxcode{countl_zero}}% |
| 1529 | +\begin{itemdescr} |
| 1530 | +\pnum |
| 1531 | +\constraints |
| 1532 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1533 | + |
| 1534 | +\pnum |
| 1535 | +\returns |
| 1536 | +The number of consecutive \tcode{0} bits in the value of \tcode{x}, |
| 1537 | +starting from the most significant bit. |
| 1538 | +\begin{note} |
| 1539 | +Returns \tcode{N} if \tcode{x == 0}. |
| 1540 | +\end{note} |
| 1541 | +\end{itemdescr} |
| 1542 | + |
| 1543 | +\begin{itemdecl} |
| 1544 | +template<class T> |
| 1545 | + constexpr int countl_one(T x) noexcept; |
| 1546 | +\end{itemdecl} |
| 1547 | + |
| 1548 | +\indexlibrary{\idxcode{countl_one}}% |
| 1549 | +\begin{itemdescr} |
| 1550 | +\pnum |
| 1551 | +\constraints |
| 1552 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1553 | + |
| 1554 | +\pnum |
| 1555 | +\returns |
| 1556 | +The number of consecutive \tcode{1} bits in the value of \tcode{x}, |
| 1557 | +starting from the most significant bit. |
| 1558 | +\begin{note} |
| 1559 | +Returns \tcode{N} if \tcode{x == numeric_limits<T>::max()}. |
| 1560 | +\end{note} |
| 1561 | +\end{itemdescr} |
| 1562 | + |
| 1563 | +\begin{itemdecl} |
| 1564 | +template<class T> |
| 1565 | + constexpr int countr_zero(T x) noexcept; |
| 1566 | +\end{itemdecl} |
| 1567 | + |
| 1568 | +\indexlibrary{\idxcode{countr_zero}}% |
| 1569 | +\begin{itemdescr} |
| 1570 | +\pnum |
| 1571 | +\constraints |
| 1572 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1573 | + |
| 1574 | +\pnum |
| 1575 | +\returns |
| 1576 | +The number of consecutive \tcode{0} bits in the value of \tcode{x}, |
| 1577 | +starting from the least significant bit. |
| 1578 | +\begin{note} |
| 1579 | +Returns \tcode{N} if \tcode{x == 0}. |
| 1580 | +\end{note} |
| 1581 | +\end{itemdescr} |
| 1582 | + |
| 1583 | +\begin{itemdecl} |
| 1584 | +template<class T> |
| 1585 | + constexpr int countr_one(T x) noexcept; |
| 1586 | +\end{itemdecl} |
| 1587 | + |
| 1588 | +\indexlibrary{\idxcode{countr_one}}% |
| 1589 | +\begin{itemdescr} |
| 1590 | +\pnum |
| 1591 | +\constraints |
| 1592 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1593 | + |
| 1594 | +\pnum |
| 1595 | +\returns |
| 1596 | +The number of consecutive \tcode{1} bits in the value of \tcode{x}, |
| 1597 | +starting from the least significant bit. |
| 1598 | +\begin{note} |
| 1599 | +Returns \tcode{N} if \tcode{x == numeric_limits<T>::max()}. |
| 1600 | +\end{note} |
| 1601 | +\end{itemdescr} |
| 1602 | + |
| 1603 | +\begin{itemdecl} |
| 1604 | +template<class T> |
| 1605 | + constexpr int popcount(T x) noexcept; |
| 1606 | +\end{itemdecl} |
| 1607 | + |
| 1608 | +\indexlibrary{\idxcode{popcount}}% |
| 1609 | +\begin{itemdescr} |
| 1610 | +\pnum |
| 1611 | +\constraints |
| 1612 | +\tcode{T} is an unsigned integer type\iref{basic.fundamental}. |
| 1613 | + |
| 1614 | +\pnum |
| 1615 | +\returns |
| 1616 | +The number of \tcode{1} bits in the value of \tcode{x}. |
| 1617 | +\end{itemdescr} |
| 1618 | + |
1453 | 1619 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1454 | 1620 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1455 | 1621 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
0 commit comments