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