|
1330 | 1330 |
|
1331 | 1331 | \pnum
|
1332 | 1332 | A type \tcode{I} is an \defnadj{integer-class}{type}
|
1333 |
| -if it is in a set of \impldef{integer-class type} class types |
| 1333 | +if it is in a set of \impldef{integer-class type} types |
1334 | 1334 | that behave as integer types do, as defined below.
|
| 1335 | +\begin{note} |
| 1336 | +An integer-class type is not necessarily a class type. |
| 1337 | +\end{note} |
1335 | 1338 |
|
1336 | 1339 | \pnum
|
1337 | 1340 | The range of representable values of an integer-class type
|
1338 | 1341 | is the continuous set of values over which it is defined.
|
1339 |
| -The values 0 and 1 are part of the range of every integer-class type. |
1340 |
| -If any negative numbers are part of the range, |
1341 |
| -the type is a \defnadj{signed-integer-class}{type}; |
1342 |
| -otherwise, it is an \defnadj{unsigned-integer-class}{type}. |
| 1342 | +For any integer-class type, |
| 1343 | +its range of representable values is |
| 1344 | +either $-2^{N-1}$ to $2^{N-1}-1$ (inclusive) for some integer $N$, |
| 1345 | +in which case it is a \defnadj{signed-integer-class}{type}, or |
| 1346 | +$0$ to $2^{N-1}$ (inclusive) for some integer $N$, |
| 1347 | +in which case it is an \defnadj{unsigned-integer-class}{type}. |
| 1348 | +In both cases, $N$ is called the width of the integer-class type. |
| 1349 | +The width of an integer-class type is greater than |
| 1350 | +that of every integral type of the same signedness. |
| 1351 | + |
| 1352 | +\pnum |
| 1353 | +A type \tcode{I} other than \cv{}~\tcode{bool} is \defn{integer-like} |
| 1354 | +if it models \tcode{\libconcept{integral}<I>} or |
| 1355 | +if it is an integer-class type. |
| 1356 | +An integer-like type \tcode{I} is \defn{signed-integer-like} |
| 1357 | +if it models \tcode{\libconcept{signed_integral}<I>} or |
| 1358 | +if it is a signed-integer-class type. |
| 1359 | +An integer-like type \tcode{I} is \defn{unsigned-integer-like} |
| 1360 | +if it models \tcode{\libconcept{unsigned_integral}<I>} or |
| 1361 | +if it is an unsigned-integer-class type. |
1343 | 1362 |
|
1344 | 1363 | \pnum
|
1345 | 1364 | For every integer-class type \tcode{I},
|
1346 |
| -let \tcode{B(I)} be a hypothetical extended integer type |
1347 |
| -of the same signedness with the smallest width\iref{basic.fundamental} |
1348 |
| -capable of representing the same range of values. |
1349 |
| -The width of \tcode{I} is equal to the width of \tcode{B(I)}. |
| 1365 | +let \tcode{B(I)} be a unique hypothetical extended integer type |
| 1366 | +of the same signedness with the same width\iref{basic.fundamental} as \tcode{I}. |
| 1367 | +\begin{note} |
| 1368 | +The corresponding hypothetical specialization \tcode{numeric_limits<B(I)>} |
| 1369 | +meets the requirements on \tcode{numeric_limits} specializations |
| 1370 | +for integral types\iref{numeric.limits}. |
| 1371 | +\end{note} |
| 1372 | +For every integral type \tcode{J}, let B(J)c be the same type as \tcode{J}. |
1350 | 1373 |
|
1351 | 1374 | \pnum
|
1352 |
| -Let \tcode{a} and \tcode{b} be objects of integer-class type \tcode{I}, |
1353 |
| -let \tcode{x} and \tcode{y} be objects of type \tcode{B(I)} as described above |
1354 |
| -that represent the same values as \tcode{a} and \tcode{b} respectively, and |
| 1375 | +Expressions of integer-class type are |
| 1376 | +explicitly convertible to any integer-like type, and |
| 1377 | +implicitly convertible to any integer-class type |
| 1378 | +of equal or greater width and the same signedness. |
| 1379 | +Expressions of integral type are |
| 1380 | +both implicitly and explicitly convertible to any integer-class type. |
| 1381 | +Conversions between integral and integer-class types |
| 1382 | +and between two integer-class types do not exit via an exception. |
| 1383 | +The result of such a conversion is the unique value of the destination type |
| 1384 | +that is congruent to the source modulo $2^N$, |
| 1385 | +where $N$ is the width of the destination type. |
| 1386 | + |
| 1387 | +\pnum |
| 1388 | +Let \tcode{a} be an object of integer-class type \tcode{I}, |
| 1389 | +let \tcode{b} be an object of integer-like type \tcode{I2} |
| 1390 | +such that the expression \tcode{b} is implicitly convertible to \tcode{I}, |
| 1391 | +let \tcode{x} and \tcode{y} be, respectively, |
| 1392 | +objects of type \tcode{B(I)} and \tcode{B(I2)} as described above |
| 1393 | +that represent the same values as \tcode{a} and \tcode{b}, and |
1355 | 1394 | let \tcode{c} be an lvalue of any integral type.
|
1356 | 1395 | \begin{itemize}
|
1357 | 1396 | \item
|
1358 |
| - For every unary operator \tcode{@} for which the expression \tcode{@x} |
| 1397 | +The expressions \tcode{a++} and \tcode{a--} shall be prvalues of type \tcode{I} |
| 1398 | +whose values are equal to |
| 1399 | +that of \tcode{a} prior to the evaluation of the expressions. |
| 1400 | +The expression \tcode{a++} shall modify the value of \tcode{a} |
| 1401 | +by adding 1 to it. |
| 1402 | +The expression \tcode{a--} shall modify the value of \tcode{a} |
| 1403 | +by subtracting 1 from it. |
| 1404 | +\item |
| 1405 | +The expressions \tcode{++a}, \tcode{--a}, and \tcode{\&a} shall be |
| 1406 | +expression-equivalent to |
| 1407 | +\tcode{a += 1}, \tcode{a -= 1}, and \tcode{addressof(a)}, respectively. |
| 1408 | +\item |
| 1409 | + For every \grammarterm{unary-operator} \tcode{@} other than \tcode{\&} for which the expression \tcode{@x} |
1359 | 1410 | is well-formed, \tcode{@a} shall also be well-formed
|
1360 |
| - and have the same value, effects, and value category as \tcode{@x} |
1361 |
| - provided that value is representable by \tcode{I}. |
| 1411 | + and have the same value, effects, and value category as \tcode{@x}. |
1362 | 1412 | If \tcode{@x} has type \tcode{bool}, so too does \tcode{@a};
|
1363 | 1413 | if \tcode{@x} has type \tcode{B(I)}, then \tcode{@a} has type \tcode{I}.
|
1364 | 1414 | \item
|
|
1368 | 1418 | shall have the same value and effects as \tcode{c @= x}.
|
1369 | 1419 | The expression \tcode{c @= a} shall be an lvalue referring to \tcode{c}.
|
1370 | 1420 | \item
|
1371 |
| - For every binary operator \tcode{@} for which \tcode{x @ y} is well-formed, |
1372 |
| - \tcode{a @ b} shall also be well-formed and |
1373 |
| - shall have the same value, effects, and value category as \tcode{x @ y} |
1374 |
| - provided that value is representable by \tcode{I}. |
1375 |
| - If \tcode{x @ y} has type \tcode{bool}, so too does \tcode{a @ b}; |
1376 |
| - if \tcode{x @ y} has type \tcode{B(I)}, then \tcode{a @ b} has type \tcode{I}. |
| 1421 | +For every assignment operator \tcode{@=} |
| 1422 | +for which \tcode{x @= y} is well-formed, |
| 1423 | +\tcode{a @= b} shall also be well-formed and |
| 1424 | +shall have the same effects as \tcode{x @= y}, |
| 1425 | +except that the value that would be stored into \tcode{x} |
| 1426 | +is stored into \tcode{a}. |
| 1427 | +The expression \tcode{a @= b} shall be an lvalue referring to \tcode{a}. |
| 1428 | +\item |
| 1429 | + For every non-assignment binary operator \tcode{@} |
| 1430 | + for which \tcode{x @ y} and \tcode{y @ x} are well-formed, |
| 1431 | + \tcode{a @ b} and \tcode{b @ a} shall also be well-formed and |
| 1432 | + shall have the same value, effects, and value category as |
| 1433 | + \tcode{x @ y} and \tcode{y @ x}, respectively. |
| 1434 | + If \tcode{x @ y} or \tcode{y @ x} has type \tcode{B(I)}, |
| 1435 | + then \tcode{a @ b} or \tcode{b @ a}, respectively, has type \tcode{I}; |
| 1436 | + if \tcode{x @ y} or \tcode{y @ x} has type \tcode{B(I2)}, |
| 1437 | + then \tcode{a @ b} or \tcode{b @ a}, respectively, has type \tcode{I2}; |
| 1438 | + if \tcode{x @ y} or \tcode{y @ x} has any other type, |
| 1439 | + then \tcode{a @ b} or \tcode{b @ a}, respectively, has that type. |
1377 | 1440 | \end{itemize}
|
1378 | 1441 |
|
1379 |
| -\pnum |
1380 |
| -Expressions of integer-class type are |
1381 |
| -explicitly convertible to any integral type. |
1382 |
| -Expressions of integral type are |
1383 |
| -both implicitly and explicitly convertible to any integer-class type. |
1384 |
| -Conversions between integral and integer-class types |
1385 |
| -do not exit via an exception. |
1386 |
| - |
1387 | 1442 | \pnum
|
1388 | 1443 | An expression \tcode{E} of integer-class type \tcode{I} is
|
1389 | 1444 | contextually convertible to \tcode{bool}
|
|
1392 | 1447 | \pnum
|
1393 | 1448 | All integer-class types model
|
1394 | 1449 | \libconcept{regular}\iref{concepts.object} and
|
1395 |
| -\libconcept{totally_ordered}\iref{concept.totallyordered}. |
| 1450 | +\libconcept{three_way_comparable}<strong_ordering>\iref{cmp.concept}. |
1396 | 1451 |
|
1397 | 1452 | \pnum
|
1398 | 1453 | A value-initialized object of integer-class type has value 0.
|
1399 | 1454 |
|
1400 | 1455 | \pnum
|
1401 | 1456 | For every (possibly cv-qualified) integer-class type \tcode{I},
|
1402 |
| -\tcode{numeric_limits<I>} is specialized such that: |
1403 |
| -\begin{itemize} |
1404 |
| -\item |
1405 |
| - \tcode{numeric_limits<I>::is_specialized} is \tcode{true}, |
1406 |
| -\item |
1407 |
| - \tcode{numeric_limits<I>::is_signed} is \tcode{true} |
1408 |
| - if and only if \tcode{I} is a signed-integer-class type, |
1409 |
| -\item |
1410 |
| - \tcode{numeric_limits<I>::is_integer} is \tcode{true}, |
1411 |
| -\item |
1412 |
| - \tcode{numeric_limits<I>::is_exact} is \tcode{true}, |
1413 |
| -\item |
1414 |
| - \tcode{numeric_limits<I>::digits} is equal to the width of the integer-class type, |
1415 |
| -\item |
1416 |
| - \tcode{numeric_limits<I>::digits10} is equal to \tcode{static_cast<int>(digits * log10(2))}, and |
1417 |
| -\item |
1418 |
| - \tcode{numeric_limits<I>::min()} and \tcode{numeric_limits<I>::max()} return |
1419 |
| - the lowest and highest representable values of \tcode{I}, respectively, and |
1420 |
| - \tcode{numeric_limits<I>::lowest()} returns \tcode{numeric_limits<I>::\brk{}min()}. |
1421 |
| -\end{itemize} |
1422 |
| - |
1423 |
| -\pnum |
1424 |
| -A type \tcode{I} other than \cv{}~\tcode{bool} is \defn{integer-like} |
1425 |
| -if it models \tcode{\libconcept{integral}<I>} or |
1426 |
| -if it is an integer-class type. |
1427 |
| -An integer-like type \tcode{I} is \defn{signed-integer-like} |
1428 |
| -if it models \tcode{\libconcept{signed_integral}<I>} or |
1429 |
| -if it is a signed-integer-class type. |
1430 |
| -An integer-like type \tcode{I} is \defn{unsigned-integer-like} |
1431 |
| -if it models \tcode{\libconcept{unsigned_integral}<I>} or |
1432 |
| -if it is an unsigned-integer-class type. |
| 1457 | +\tcode{numeric_limits<I>} is specialized such that |
| 1458 | +each static data member \tcode{m} |
| 1459 | +has the same value as \tcode{numeric_limits<B(I)>::m}, and |
| 1460 | +each static member function \tcode{f} |
| 1461 | +returns \tcode{I(numeric_limits<B(I)>::f())}. |
| 1462 | + |
| 1463 | +\pnum |
| 1464 | +For any two integer-like types \tcode{I1} and \tcode{I2}, |
| 1465 | +at least one of which is an integer-class type, |
| 1466 | +\tcode{common_type_t<I1, I2>} denotes an integer-class type |
| 1467 | +whose width is not less than that of \tcode{I1} or \tcode{I2}. |
| 1468 | +If both \tcode{I1} and \tcode{I2} are signed-integer-like types, |
| 1469 | +then \tcode{common_type_t<I1, I2>} is also a signed-integer-like type. |
1433 | 1470 |
|
1434 | 1471 | \pnum
|
1435 | 1472 | \tcode{\exposid{is-integer-like}<I>} is \tcode{true}
|
|
0 commit comments