Skip to content

Commit a5938ea

Browse files
Dawn Perchikzygoloid
authored andcommitted
P1892R1 Extended locale-specific presentation specifiers for std::format
Also fixes NB GB 226 (C++20 CD).
1 parent cbd19c5 commit a5938ea

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

source/utilities.tex

Lines changed: 21 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,22 @@
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+
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+
1988319899
\pnum
1988419900
The \fmtgrammarterm{type} determines how the data should be presented.
1988519901

@@ -19919,7 +19935,7 @@
1991919935
string s0 = format("{}", 42); // value of \tcode{s0} is \tcode{"42"}
1992019936
string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of \tcode{s1} is \tcode{"101010 42 52 2a"}
1992119937
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"}
1992319939
// (depending on the locale)
1992419940
\end{codeblock}
1992519941
\end{example}
@@ -19968,12 +19984,6 @@
1996819984
the base prefix is \tcode{0X}.
1996919985
\\ \rowsep
1997019986
%
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-
%
1997719987
none &
1997819988
The same as \tcode{d}.
1997919989
\begin{note}
@@ -19993,7 +20003,7 @@
1999320003
Copies the character to the output.
1999420004
\\ \rowsep
1999520005
%
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} &
1999720007
As specified in \tref{format.type.int}.
1999820008
\\
1999920009
\end{floattable}
@@ -20009,7 +20019,7 @@
2000920019
Copies textual representation, either \tcode{true} or \tcode{false}, to the output.
2001020020
\\ \rowsep
2001120021
%
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} &
2001320023
As specified in \tref{format.type.int}
2001420024
for the value
2001520025
\tcode{static_cast<unsigned char>(value)}.
@@ -20087,12 +20097,6 @@
2008720097
it uses \tcode{E} to indicate exponent.
2008820098
\\ \rowsep
2008920099
%
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-
%
2009620100
none &
2009720101
If \fmtgrammarterm{precision} is specified, equivalent to
2009820102
\begin{codeblock}

0 commit comments

Comments
 (0)