Skip to content

Commit

Permalink
Merge 2019-11 LWG Motion 22
Browse files Browse the repository at this point in the history
P1892R1 Extended locale-specific presentation specifiers for std::format
  • Loading branch information
zygoloid committed Nov 24, 2019
2 parents cbd19c5 + d1d3793 commit 3e4ce14
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19682,7 +19682,7 @@

\begin{ncbnf}
\fmtnontermdef{std-format-spec}\br
\opt{fill-and-align} \opt{sign} \opt{\terminal{\#}} \opt{\terminal{0}} \opt{width} \opt{precision} \opt{type}
\opt{fill-and-align} \opt{sign} \opt{\terminal{\#}} \opt{\terminal{0}} \opt{width} \opt{precision} \opt{\terminal{L}} \opt{type}
\end{ncbnf}

\begin{ncbnf}
Expand Down Expand Up @@ -19719,7 +19719,7 @@

\begin{ncbnf}
\fmtnontermdef{type} \textnormal{one of}\br
\terminal{a A b B c d e E f F g G n o p s x X}
\terminal{a A b B c d e E f F g G o p s x X}
\end{ncbnf}

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

\pnum
When the \tcode{L} option is used, the form used for the conversion is called
the \defnx{locale-specific form}{locale-specific form!format string}.
The \tcode{L} option is only valid for arithmetic types, and
its effect depends upon the type.
\begin{itemize}
\item
For integral types, the locale-specific form
causes the context's locale to be used
to insert the appropriate digit group separator characters.

\item
For floating-point types, the locale-specific form
causes the context's locale to be used
to insert the appropriate digit group and radix separator characters.

\item
For the textual representation of \tcode{bool}, the locale-specific form
causes the context's locale to be used
to insert the appropriate string as if obtained
with \tcode{numpunct::truename} or \tcode{numpunct::falsename}.
\end{itemize}

\pnum
The \fmtgrammarterm{type} determines how the data should be presented.

Expand Down Expand Up @@ -19919,7 +19942,7 @@
string s0 = format("{}", 42); // value of \tcode{s0} is \tcode{"42"}
string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of \tcode{s1} is \tcode{"101010 42 52 2a"}
string s2 = format("{0:#x} {0:#X}", 42); // value of \tcode{s2} is \tcode{"0x2a 0X2A"}
string s3 = format("{:n}", 1234); // value of \tcode{s3} might be \tcode{"1,234"}
string s3 = format("{:L}", 1234); // value of \tcode{s3} might be \tcode{"1,234"}
// (depending on the locale)
\end{codeblock}
\end{example}
Expand Down Expand Up @@ -19968,12 +19991,6 @@
the base prefix is \tcode{0X}.
\\ \rowsep
%
\tcode{n} &
The same as \tcode{d}, except that
it uses the context's locale
to insert the appropriate digit group separator characters.
\\ \rowsep
%
none &
The same as \tcode{d}.
\begin{note}
Expand All @@ -19993,7 +20010,7 @@
Copies the character to the output.
\\ \rowsep
%
\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} &
\tcode{b}, \tcode{B}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} &
As specified in \tref{format.type.int}.
\\
\end{floattable}
Expand All @@ -20009,7 +20026,7 @@
Copies textual representation, either \tcode{true} or \tcode{false}, to the output.
\\ \rowsep
%
\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X}, \tcode{n} &
\tcode{b}, \tcode{B}, \tcode{c}, \tcode{d}, \tcode{o}, \tcode{x}, \tcode{X} &
As specified in \tref{format.type.int}
for the value
\tcode{static_cast<unsigned char>(value)}.
Expand Down Expand Up @@ -20087,12 +20104,6 @@
it uses \tcode{E} to indicate exponent.
\\ \rowsep
%
\tcode{n} &
The same as \tcode{g}, except that
it uses the context's locale to insert the appropriate
digit group and decimal radix separator characters.
\\ \rowsep
%
none &
If \fmtgrammarterm{precision} is specified, equivalent to
\begin{codeblock}
Expand Down

0 comments on commit 3e4ce14

Please sign in to comment.