|
19682 | 19682 |
|
19683 | 19683 | \begin{ncbnf}
|
19684 | 19684 | \fmtnontermdef{std-format-spec}\br
|
19685 |
| - \opt{fill-and-align} \opt{sign} \opt{\terminal{\#}} \opt{\terminal{0}} \opt{width} \opt{precision} \opt{type} |
| 19685 | + \opt{fill-and-align} \opt{sign} \opt{\terminal{\#}} \opt{\terminal{0}} \opt{width} \opt{precision} \opt{\terminal{L}} \opt{type} |
19686 | 19686 | \end{ncbnf}
|
19687 | 19687 |
|
19688 | 19688 | \begin{ncbnf}
|
|
19719 | 19719 |
|
19720 | 19720 | \begin{ncbnf}
|
19721 | 19721 | \fmtnontermdef{type} \textnormal{one of}\br
|
19722 |
| - \terminal{a A b B c d e E f F g G n o p s x X} |
| 19722 | + \terminal{a A b B c d e E f F g G o p s x X} |
19723 | 19723 | \end{ncbnf}
|
19724 | 19724 |
|
19725 | 19725 | \pnum
|
|
19880 | 19880 | For floating-point types this field specifies the formatting precision.
|
19881 | 19881 | For string types it specifies how many characters will be used from the string.
|
19882 | 19882 |
|
| 19883 | +\pnum |
| 19884 | +When the \tcode{L} option is used, the form used for the conversion is called |
| 19885 | +the \defnx{locale-specific form}{locale-specific form!format string}. |
| 19886 | +The \tcode{L} option is only valid for arithmetic types, and |
| 19887 | +its effect depends upon the type. |
| 19888 | +\begin{itemize} |
| 19889 | +\item |
| 19890 | +For integral types, the locale-specific form |
| 19891 | +causes the context's locale to be used |
| 19892 | +to insert the appropriate digit group separator characters. |
| 19893 | + |
| 19894 | +\item |
| 19895 | +For floating-point types, the locale-specific form |
| 19896 | +causes the context's locale to be used |
| 19897 | +to insert the appropriate digit group and radix separator characters. |
| 19898 | + |
| 19899 | +\item |
| 19900 | +For the textual representation of \tcode{bool}, the locale-specific form |
| 19901 | +causes the context's locale to be used |
| 19902 | +to insert the appropriate string as if obtained |
| 19903 | +with \tcode{numpunct::truename} or \tcode{numpunct::falsename}. |
| 19904 | +\end{itemize} |
| 19905 | + |
19883 | 19906 | \pnum
|
19884 | 19907 | The \fmtgrammarterm{type} determines how the data should be presented.
|
19885 | 19908 |
|
|
19919 | 19942 | string s0 = format("{}", 42); // value of \tcode{s0} is \tcode{"42"}
|
19920 | 19943 | string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of \tcode{s1} is \tcode{"101010 42 52 2a"}
|
19921 | 19944 | string s2 = format("{0:#x} {0:#X}", 42); // value of \tcode{s2} is \tcode{"0x2a 0X2A"}
|
19922 |
| -string s3 = format("{:n}", 1234); // value of \tcode{s3} might be \tcode{"1,234"} |
| 19945 | +string s3 = format("{:L}", 1234); // value of \tcode{s3} might be \tcode{"1,234"} |
19923 | 19946 | // (depending on the locale)
|
19924 | 19947 | \end{codeblock}
|
19925 | 19948 | \end{example}
|
|
19968 | 19991 | the base prefix is \tcode{0X}.
|
19969 | 19992 | \\ \rowsep
|
19970 | 19993 | %
|
19971 |
| -\tcode{n} & |
19972 |
| -The same as \tcode{d}, except that |
19973 |
| -it uses the context's locale |
19974 |
| -to insert the appropriate digit group separator characters. |
19975 |
| -\\ \rowsep |
19976 |
| -% |
19977 | 19994 | none &
|
19978 | 19995 | The same as \tcode{d}.
|
19979 | 19996 | \begin{note}
|
|
19993 | 20010 | Copies the character to the output.
|
19994 | 20011 | \\ \rowsep
|
19995 | 20012 | %
|
19996 |
| -\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} & |
| 20013 | +\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} & |
19997 | 20014 | As specified in \tref{format.type.int}.
|
19998 | 20015 | \\
|
19999 | 20016 | \end{floattable}
|
|
20009 | 20026 | Copies textual representation, either \tcode{true} or \tcode{false}, to the output.
|
20010 | 20027 | \\ \rowsep
|
20011 | 20028 | %
|
20012 |
| -\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} & |
| 20029 | +\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} & |
20013 | 20030 | As specified in \tref{format.type.int}
|
20014 | 20031 | for the value
|
20015 | 20032 | \tcode{static_cast<unsigned char>(value)}.
|
|
20087 | 20104 | it uses \tcode{E} to indicate exponent.
|
20088 | 20105 | \\ \rowsep
|
20089 | 20106 | %
|
20090 |
| -\tcode{n} & |
20091 |
| -The same as \tcode{g}, except that |
20092 |
| -it uses the context's locale to insert the appropriate |
20093 |
| -digit group and decimal radix separator characters. |
20094 |
| -\\ \rowsep |
20095 |
| -% |
20096 | 20107 | none &
|
20097 | 20108 | If \fmtgrammarterm{precision} is specified, equivalent to
|
20098 | 20109 | \begin{codeblock}
|
|
0 commit comments