|
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 | +The \tcode{L} option causes |
| 19885 | +the \defnx{locale-specific form}{locale-specific form!format string} |
| 19886 | +to be used for the conversion. |
| 19887 | +This option is only valid for arithmetic types. |
| 19888 | +For integral types, the locale-specific form |
| 19889 | +causes the context's locale to be used |
| 19890 | +to insert the appropriate digit group separator characters. |
| 19891 | +For floating-point types, the locale-specific form |
| 19892 | +causes the context's locale to be used |
| 19893 | +to insert the appropriate digit group and decimal radix separator characters. |
| 19894 | +For the textual representation of \tcode{bool}, the locale-specific form |
| 19895 | +causes the context's locale to be used |
| 19896 | +to insert the appropriate string as if obtained |
| 19897 | +with \tcode{numpunct::truename} or \tcode{numpunct::falsename}. |
| 19898 | + |
19883 | 19899 | \pnum
|
19884 | 19900 | The \fmtgrammarterm{type} determines how the data should be presented.
|
19885 | 19901 |
|
|
19919 | 19935 | string s0 = format("{}", 42); // value of \tcode{s0} is \tcode{"42"}
|
19920 | 19936 | string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of \tcode{s1} is \tcode{"101010 42 52 2a"}
|
19921 | 19937 | 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"} |
| 19938 | +string s3 = format("{:L}", 1234); // value of \tcode{s3} might be \tcode{"1,234"} |
19923 | 19939 | // (depending on the locale)
|
19924 | 19940 | \end{codeblock}
|
19925 | 19941 | \end{example}
|
|
19968 | 19984 | the base prefix is \tcode{0X}.
|
19969 | 19985 | \\ \rowsep
|
19970 | 19986 | %
|
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 | 19987 | none &
|
19978 | 19988 | The same as \tcode{d}.
|
19979 | 19989 | \begin{note}
|
|
19993 | 20003 | Copies the character to the output.
|
19994 | 20004 | \\ \rowsep
|
19995 | 20005 | %
|
19996 |
| -\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} & |
| 20006 | +\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} & |
19997 | 20007 | As specified in \tref{format.type.int}.
|
19998 | 20008 | \\
|
19999 | 20009 | \end{floattable}
|
|
20009 | 20019 | Copies textual representation, either \tcode{true} or \tcode{false}, to the output.
|
20010 | 20020 | \\ \rowsep
|
20011 | 20021 | %
|
20012 |
| -\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} & |
| 20022 | +\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} & |
20013 | 20023 | As specified in \tref{format.type.int}
|
20014 | 20024 | for the value
|
20015 | 20025 | \tcode{static_cast<unsigned char>(value)}.
|
|
20087 | 20097 | it uses \tcode{E} to indicate exponent.
|
20088 | 20098 | \\ \rowsep
|
20089 | 20099 | %
|
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 | 20100 | none &
|
20097 | 20101 | If \fmtgrammarterm{precision} is specified, equivalent to
|
20098 | 20102 | \begin{codeblock}
|
|
0 commit comments