Skip to content

Commit 802393a

Browse files
authored
Merge 2018-06 LWG Motion 23
Fixes #2140
2 parents a2e415a + 4a9d893 commit 802393a

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

source/numerics.tex

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,16 @@
13771377
// \ref{bit.cast}, \tcode{bit_cast}
13781378
template<typename To, typename From>
13791379
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;
13801390
}
13811391
\end{codeblock}
13821392

@@ -1419,6 +1429,84 @@
14191429
\end{itemize}
14201430
\end{itemdescr}
14211431

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+
14221510
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14231511
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14241512
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0 commit comments

Comments
 (0)