Skip to content

Commit d8a37d2

Browse files
committed
Merge 2019-07 LWG Motion 2
P1355R2 Exposing a narrow contract for ceil2 Fixes #3006.
2 parents 00b61e5 + 73804f8 commit d8a37d2

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

source/numerics.tex

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@
13121312
template<class T>
13131313
constexpr bool ispow2(T x) noexcept;
13141314
template<class T>
1315-
constexpr T ceil2(T x) noexcept;
1315+
constexpr T ceil2(T x);
13161316
template<class T>
13171317
constexpr T floor2(T x) noexcept;
13181318
template<class T>
@@ -1382,21 +1382,34 @@
13821382
\indexlibrary{\idxcode{ceil2}}%
13831383
\begin{itemdecl}
13841384
template<class T>
1385-
constexpr T ceil2(T x) noexcept;
1385+
constexpr T ceil2(T x);
13861386
\end{itemdecl}
13871387

13881388
\begin{itemdescr}
1389+
\pnum
1390+
Let $N$ be the smallest power of 2 greater than or equal to \tcode{x}.
1391+
1392+
\pnum
1393+
\constraints
1394+
\tcode{T} is an unsigned integer type\iref{basic.fundamental}.
1395+
1396+
\pnum
1397+
\expects
1398+
$N$ is representable as a value of type \tcode{T}.
1399+
13891400
\pnum
13901401
\returns
1391-
The minimal value \tcode{y} such that
1392-
\tcode{ispow2(y)} is \tcode{true} and \tcode{y >= x};
1393-
if \tcode{y} is not representable as a value of type \tcode{T},
1394-
the result is an unspecified value.
1402+
$N$.
1403+
1404+
\pnum
1405+
\throws
1406+
Nothing.
13951407

13961408
\pnum
13971409
\remarks
1398-
This function shall not participate in overload resolution
1399-
unless \tcode{T} is an unsigned integer type\iref{basic.fundamental}.
1410+
A function call expression
1411+
that violates the precondition in the \expects element
1412+
is not a core constant expression\iref{expr.const}.
14001413
\end{itemdescr}
14011414

14021415
\indexlibrary{\idxcode{floor2}}%

0 commit comments

Comments
 (0)