Skip to content

Commit 3e4ce14

Browse files
authored
Merge 2019-11 LWG Motion 22
P1892R1 Extended locale-specific presentation specifiers for std::format
2 parents cbd19c5 + d1d3793 commit 3e4ce14

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

source/utilities.tex

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19682,7 +19682,7 @@
1968219682

1968319683
\begin{ncbnf}
1968419684
\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}
1968619686
\end{ncbnf}
1968719687

1968819688
\begin{ncbnf}
@@ -19719,7 +19719,7 @@
1971919719

1972019720
\begin{ncbnf}
1972119721
\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}
1972319723
\end{ncbnf}
1972419724

1972519725
\pnum
@@ -19880,6 +19880,29 @@
1988019880
For floating-point types this field specifies the formatting precision.
1988119881
For string types it specifies how many characters will be used from the string.
1988219882

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+
1988319906
\pnum
1988419907
The \fmtgrammarterm{type} determines how the data should be presented.
1988519908

@@ -19919,7 +19942,7 @@
1991919942
string s0 = format("{}", 42); // value of \tcode{s0} is \tcode{"42"}
1992019943
string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of \tcode{s1} is \tcode{"101010 42 52 2a"}
1992119944
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"}
1992319946
// (depending on the locale)
1992419947
\end{codeblock}
1992519948
\end{example}
@@ -19968,12 +19991,6 @@
1996819991
the base prefix is \tcode{0X}.
1996919992
\\ \rowsep
1997019993
%
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-
%
1997719994
none &
1997819995
The same as \tcode{d}.
1997919996
\begin{note}
@@ -19993,7 +20010,7 @@
1999320010
Copies the character to the output.
1999420011
\\ \rowsep
1999520012
%
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} &
1999720014
As specified in \tref{format.type.int}.
1999820015
\\
1999920016
\end{floattable}
@@ -20009,7 +20026,7 @@
2000920026
Copies textual representation, either \tcode{true} or \tcode{false}, to the output.
2001020027
\\ \rowsep
2001120028
%
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} &
2001320030
As specified in \tref{format.type.int}
2001420031
for the value
2001520032
\tcode{static_cast<unsigned char>(value)}.
@@ -20087,12 +20104,6 @@
2008720104
it uses \tcode{E} to indicate exponent.
2008820105
\\ \rowsep
2008920106
%
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-
%
2009620107
none &
2009720108
If \fmtgrammarterm{precision} is specified, equivalent to
2009820109
\begin{codeblock}

0 commit comments

Comments
 (0)