|
829 | 829 |
|
830 | 830 | \rSec2[conv.prom]{Integral promotions} |
831 | 831 |
|
| 832 | +\pnum |
| 833 | +For the purposes of \ref{conv.prom}, |
| 834 | +a \defnadj{converted}{bit-field} is a prvalue that is the result of |
| 835 | +an lvalue-to-rvalue conversion\iref{conv.lval} applied to |
| 836 | +a bit-field\iref{class.bit}. |
| 837 | + |
832 | 838 | \pnum |
833 | 839 | \indextext{promotion!integral}% |
834 | | -A prvalue of an integer type other than \keyword{bool}, \keyword{char8_t}, \keyword{char16_t}, |
| 840 | +A prvalue that is not a converted bit-field and has an integer type other than |
| 841 | +\keyword{bool}, \keyword{char8_t}, \keyword{char16_t}, |
835 | 842 | \keyword{char32_t}, or \keyword{wchar_t} whose integer conversion |
836 | 843 | rank\iref{conv.rank} is less than the rank of \keyword{int} can be |
837 | 844 | converted to a prvalue of type \keyword{int} if \keyword{int} can represent |
838 | 845 | all the values of the source type; otherwise, the source prvalue can be |
839 | 846 | converted to a prvalue of type \tcode{\keyword{unsigned} \keyword{int}}. |
840 | 847 |
|
841 | | -\pnum |
842 | | -\indextext{type!underlying!\idxcode{wchar_t}}% |
843 | | -\indextext{type!underlying!\idxcode{char16_t}}% |
844 | | -\indextext{type!underlying!\idxcode{char32_t}}% |
845 | | -A prvalue of type \keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or |
846 | | -\keyword{wchar_t}\iref{basic.fundamental} can be converted to a prvalue |
847 | | -of the first of the following types that can represent all the values of |
848 | | -its underlying type: \keyword{int}, \tcode{\keyword{unsigned} \keyword{int}}, \tcode{\keyword{long} \keyword{int}}, |
849 | | -\tcode{\keyword{unsigned} \keyword{long} \keyword{int}}, \tcode{\keyword{long} \keyword{long} \keyword{int}}, |
850 | | -or \tcode{\keyword{unsigned} \keyword{long} \keyword{long} \keyword{int}}. If none of the types in that list can |
851 | | -represent all the values of its underlying type, a prvalue of type |
852 | | -\keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or \keyword{wchar_t} can be converted |
853 | | -to a prvalue of its underlying type. |
854 | | - |
855 | 848 | \pnum |
856 | 849 | \indextext{type!underlying!enumeration}% |
857 | 850 | A prvalue of an unscoped enumeration type whose underlying type is not |
|
871 | 864 | if integral promotion can be applied to its underlying type, a prvalue of an unscoped |
872 | 865 | enumeration type whose underlying type is fixed can also be converted to a prvalue of |
873 | 866 | the promoted underlying type. |
| 867 | +\begin{note} |
| 868 | +A converted bit-field of enumeration type is treated as |
| 869 | +any other value of that type for promotion purposes. |
| 870 | +\end{note} |
874 | 871 |
|
875 | 872 | \pnum |
876 | | -A prvalue for an integral bit-field\iref{class.bit} can be converted |
| 873 | +A converted bit-field of integral type can be converted |
877 | 874 | to a prvalue of type \keyword{int} if \keyword{int} can represent all the |
878 | 875 | values of the bit-field; otherwise, it can be converted to |
879 | 876 | \tcode{\keyword{unsigned} \keyword{int}} if \tcode{\keyword{unsigned} \keyword{int}} can represent all the |
880 | | -values of the bit-field. If the bit-field is larger yet, no integral |
881 | | -promotion applies to it. If the bit-field has enumeration type, it is |
882 | | -treated as any other value of that type for promotion purposes. |
| 877 | +values of the bit-field. |
| 878 | + |
| 879 | +\pnum |
| 880 | +\indextext{type!underlying!\idxcode{wchar_t}}% |
| 881 | +\indextext{type!underlying!\idxcode{char16_t}}% |
| 882 | +\indextext{type!underlying!\idxcode{char32_t}}% |
| 883 | +A prvalue of type |
| 884 | +\keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, or |
| 885 | +\keyword{wchar_t}\iref{basic.fundamental} |
| 886 | +(including a converted bit-field that was not |
| 887 | +already promoted to \keyword{int} or \tcode{\keyword{unsigned} \keyword{int}} |
| 888 | +according to the rules above) |
| 889 | +can be converted to a prvalue |
| 890 | +of the first of the following types that can represent all the values of |
| 891 | +its underlying type: |
| 892 | +\keyword{int}, |
| 893 | +\tcode{\keyword{unsigned} \keyword{int}}, |
| 894 | +\tcode{\keyword{long} \keyword{int}}, |
| 895 | +\tcode{\keyword{unsigned} \keyword{long} \keyword{int}}, |
| 896 | +\tcode{\keyword{long} \keyword{long} \keyword{int}}, |
| 897 | +\tcode{\keyword{unsigned} \keyword{long} \keyword{long} \keyword{int}}, or |
| 898 | +its underlying type. |
883 | 899 |
|
884 | 900 | \pnum |
885 | 901 | \indextext{promotion!bool to int}% |
|
0 commit comments