19618
19618
19619
19619
\rSec2[format.string]{Format string}
19620
19620
19621
+ \rSec3[format.string.general]{In general}
19622
+
19621
19623
% FIXME: For now, keep the format grammar productions out of the index, since
19622
19624
% they conflict with the main grammar.
19623
19625
% Consider renaming these en masse (to fmt-* ?) to avoid this problem.
19639
19641
19640
19642
\begin{ncbnf}
19641
19643
\fmtnontermdef{replacement-field}\br
19642
- \terminal{\{} \opt{arg-id} \opt{format-spec } \terminal{\}}
19644
+ \terminal{\{} \opt{arg-id} \opt{format-specifier } \terminal{\}}
19643
19645
\end{ncbnf}
19644
19646
19645
19647
\begin{ncbnf}
@@ -19671,13 +19673,23 @@
19671
19673
\terminal{0 1 2 3 4 5 6 7 8 9}
19672
19674
\end{ncbnf}
19673
19675
19676
+ \begin{ncbnf}
19677
+ \fmtnontermdef{format-specifier}\br
19678
+ \terminal{:} format-spec
19679
+ \end{ncbnf}
19680
+
19681
+ \begin{ncbnf}
19682
+ \fmtnontermdef{format-spec}\br
19683
+ \textnormal{as specified by the \tcode{formatter} specialization for the argument type}
19684
+ \end{ncbnf}
19685
+
19674
19686
\pnum
19675
19687
The \fmtgrammarterm{arg-id} field specifies the index of
19676
19688
% FIXME: "args" hasn't been introduced yet!
19677
19689
the argument in \tcode{args}
19678
19690
whose value is to be formatted and inserted into the output
19679
19691
instead of the replacement field.
19680
- The optional \fmtgrammarterm{format-spec } field
19692
+ The optional \fmtgrammarterm{format-specifier } field
19681
19693
explicitly specifies a format for the replacement value.
19682
19694
19683
19695
\pnum
19688
19700
\end{example}
19689
19701
19690
19702
\pnum
19691
- If all \fmtgrammarterm{arg-id}s in a format string are omitted,
19703
+ If all \fmtgrammarterm{arg-id}s in a format string are omitted
19704
+ (including those in the \fmtgrammarterm{format-spec},
19705
+ as interpreted by the corresponding \tcode{formatter} specialization),
19692
19706
argument indexes 0, 1, 2, \ldots{} will automatically be used in that order.
19693
19707
If some \fmtgrammarterm{arg-id}s are omitted and some are present,
19694
19708
the string is not a format string.
@@ -19710,27 +19724,44 @@
19710
19724
\pnum
19711
19725
The \fmtgrammarterm{format-spec} field contains
19712
19726
\defnx{format specifications}{format specification!format string}
19713
- that define how the value should be presented,
19714
- including such details as
19715
- field width, alignment, padding, and decimal precision.
19727
+ that define how the value should be presented.
19716
19728
Each type can define its own
19717
- formatting mini-language or
19718
19729
interpretation of the \fmtgrammarterm{format-spec} field.
19719
- The syntax of format specifications is as follows:
19730
+ \begin{example}
19731
+ \begin{itemize}
19732
+ \item
19733
+ For arithmetic, pointer, and string types
19734
+ the \fmtgrammarterm{format-spec}
19735
+ is interpreted as a \fmtgrammarterm{std-format-spec}
19736
+ as described in \iref{format.string.std}.
19737
+ \item
19738
+ For chrono types
19739
+ the \fmtgrammarterm{format-spec}
19740
+ is interpreted as a \fmtgrammarterm{chrono-format-spec}
19741
+ as described in \iref{time.format}.
19742
+ \item
19743
+ For user-defined \tcode{formatter} specializations,
19744
+ the behavior of the \tcode{parse} member function
19745
+ determines how the \fmtgrammarterm{format-spec}
19746
+ is interpreted.
19747
+ \end{itemize}
19748
+ \end{example}
19720
19749
19721
- % FIXME: Listing chrono-format-spec here is a mistake. We should have a clean
19722
- % separation between the extensibility mechanism and the extensions to it.
19723
- \begin{ncbnf}
19724
- \fmtnontermdef{format-spec}\br
19725
- \terminal{:} std-format-spec\br
19726
- \terminal{:} chrono-format-spec\br
19727
- \terminal{:} custom-format-spec
19728
- \end{ncbnf}
19750
+ \rSec3[format.string.std]{Standard format specifiers}
19729
19751
19730
- \begin{ncbnf}
19731
- \fmtnontermdef{custom-format-spec}\br
19732
- \textnormal{user-defined syntax dependent on the type of the argument}
19733
- \end{ncbnf}
19752
+ \pnum
19753
+ Each \tcode{formatter} specializations
19754
+ described in \ref{format.formatter.spec}
19755
+ for fundamental and string types
19756
+ interprets \fmtgrammarterm{format-spec} as a
19757
+ \fmtgrammarterm{std-format-spec}.
19758
+ \begin{note}
19759
+ The format specification can be used to specify such details as
19760
+ field width, alignment, padding, and decimal precision.
19761
+ Some of the formatting options
19762
+ are only supported for arithmetic types.
19763
+ \end{note}
19764
+ The syntax of format specifications is as follows:
19734
19765
19735
19766
\begin{ncbnf}
19736
19767
\fmtnontermdef{std-format-spec}\br
19774
19805
\terminal{a A b B c d e E f F g G n o p s x X}
19775
19806
\end{ncbnf}
19776
19807
19777
- where
19778
- \fmtgrammarterm{std-format-spec}
19779
- defines a common formatting mini-language
19780
- supported by fundamental and string types,
19781
- \fmtgrammarterm{chrono-format-spec}
19782
- defines a mini-language for chrono types\iref{time.format}, and
19783
- \fmtgrammarterm{custom-format-spec}
19784
- is a placeholder for user-defined mini-languages.
19785
- \begin{note}
19786
- Some of the formatting options
19787
- are only supported for arithmetic types.
19788
- \end{note}
19789
-
19790
19808
\pnum
19791
19809
\begin{note}
19792
19810
The \fmtgrammarterm{fill} character can be any character
@@ -20514,10 +20532,14 @@
20514
20532
\item a floating-point type.
20515
20533
\end{itemize}
20516
20534
\end{itemize}
20517
-
20535
+ The \tcode{parse} member functions of these formatters
20536
+ interpret the format specification
20537
+ as a \fmtgrammarterm{std-format-spec}
20538
+ as described in \ref{format.string.std}.
20518
20539
\begin{note}
20519
20540
Specializations such as \tcode{formatter<wchar_t, char>}
20520
- and \tcode{formatter<const char*, wchar_t>} that require implicit
20541
+ and \tcode{formatter<const char*, wchar_t>}
20542
+ that would require implicit
20521
20543
multibyte / wide string or character conversion are disabled.
20522
20544
\end{note}
20523
20545
0 commit comments