13859
13859
// \ref {format.formatter }, formatter
13860
13860
template<class T, class charT = char> struct formatter;
13861
13861
13862
- // \ref {format.range.formatter }, class template \tcode {range_formatter}
13862
+ // \ref {format.formattable }, concept \libconcept {formattable}
13863
+ template<class T, class charT>
13864
+ concept formattable = @\seebelow@ ;
13865
+
13866
+ template<class R, class charT>
13867
+ concept @\defexposconcept {const-formattable-range}@ = // \expos
13868
+ ranges::@\libconcept {input_range}@<const R> &&
13869
+ @\libconcept {formattable}@<ranges::range_reference_t<const R>, charT>;
13870
+
13871
+ template<class R, class charT>
13872
+ using @\exposid {fmt-maybe-const}@ = // \expos
13873
+ conditional_t<@\exposconcept {const-formattable-range}@<R, charT>, const R, R>;
13874
+
13875
+ // \ref {format.parse.ctx }, class template \tcode {basic_format_parse_context}
13876
+ template<class charT> class basic_format_parse_context;
13877
+ using format_parse_context = basic_format_parse_context<char>;
13878
+ using wformat_parse_context = basic_format_parse_context<wchar_t>;
13879
+
13880
+ // \ref {format.range }, formatting of ranges
13881
+ // \ref {format.range.fmtkind }, variable template \tcode {format_kind}
13863
13882
enum class range_format {
13864
13883
disabled,
13865
13884
map,
@@ -13876,37 +13895,21 @@
13876
13895
requires @\libconcept {same_as}@<R, remove_cvref_t<R>>
13877
13896
constexpr range_format format_kind<R> = @\seebelow@ ;
13878
13897
13898
+ // \ref {format.range.formatter }, class template \tcode {range_formatter}
13879
13899
template<class T, class charT = char>
13880
13900
requires @\libconcept {same_as}@<remove_cvref_t<T>, T> && @\libconcept {formattable}@<T, charT>
13881
13901
class range_formatter;
13882
13902
13903
+ // \ref {format.range.fmtdef }, class template \tcode {\exposid {range-default-formatter}}
13883
13904
template<range_format K, ranges::@\libconcept {input_range}@ R, class charT>
13884
13905
struct @\exposid {range-default-formatter}@; // \expos
13885
13906
13886
- // \ref {format.formatter.spec }, formatter specializations
13907
+ // \ref {format.range.fmtmap }, \ref { format.range.fmtset }, \ref { format.range.fmtstr }, specializations for maps, sets, and strings
13887
13908
template<ranges::@\libconcept {input_range}@ R, class charT>
13888
13909
requires (format_kind<R> != range_format::disabled) &&
13889
13910
@\libconcept {formattable}@<ranges::range_reference_t<R>, charT>
13890
13911
struct formatter<R, charT> : @\exposid {range-default-formatter}@<format_kind<R>, R, charT> { };
13891
13912
13892
- // \ref {format.parse.ctx }, class template \tcode {basic_format_parse_context}
13893
- template<class charT> class basic_format_parse_context;
13894
- using format_parse_context = basic_format_parse_context<char>;
13895
- using wformat_parse_context = basic_format_parse_context<wchar_t>;
13896
-
13897
- // \ref {format.formattable }, concept \libconcept {formattable}
13898
- template<class T, class charT>
13899
- concept formattable = @\seebelow@ ;
13900
-
13901
- template<class R, class charT>
13902
- concept @\defexposconcept {const-formattable-range}@ = // \expos
13903
- ranges::@\libconcept {input_range}@<const R> &&
13904
- @\libconcept {formattable}@<ranges::range_reference_t<const R>, charT>;
13905
-
13906
- template<class R, class charT>
13907
- using @\exposid {fmt-maybe-const}@ = // \expos
13908
- conditional_t<@\exposconcept {const-formattable-range}@<R, charT>, const R, R>;
13909
-
13910
13913
// \ref {format.arguments }, arguments
13911
13914
// \ref {format.arg }, class template \tcode {basic_format_arg}
13912
13915
template<class Context> class basic_format_arg;
15668
15671
\end {codeblock }
15669
15672
\end {example }
15670
15673
15671
- \rSec 2[format.range.formatter]{Class template \tcode {range_formatter}}
15674
+ \rSec 2[format.range]{Formatting of ranges}
15675
+
15676
+ \rSec 3[format.range.fmtkind]{Variable template \tcode {format_kind}}
15677
+
15678
+ \indexlibraryglobal {format_kind}
15679
+ \begin {itemdecl }
15680
+ template<ranges::@\libconcept {input_range}@ R>
15681
+ requires @\libconcept {same_as}@<R, remove_cvref_t<R>>
15682
+ constexpr range_format format_kind<R> = @\seebelow@ ;
15683
+ \end {itemdecl }
15684
+
15685
+ \begin {itemdescr }
15686
+ \pnum
15687
+ A program that instantiates the primary template of \tcode {format_kind}
15688
+ is ill-formed.
15689
+
15690
+ \pnum
15691
+ For a type \tcode {R}, \tcode {format_kind<R>} is defined as follows:
15692
+ \begin {itemize }
15693
+ \item
15694
+ If \tcode {\libconcept {same_as}<remove_cvref_t<ranges::range_reference_t<R>>, R>}
15695
+ is \tcode {true},
15696
+ \tcode {format_kind<R>} is \tcode {range_format::disabled}.
15697
+ \begin {note }
15698
+ This prevents constraint recursion for ranges whose
15699
+ reference type is the same range type.
15700
+ For example,
15701
+ \tcode {std::filesystem::path} is a range of \tcode {std::filesystem::path}.
15702
+ \end {note }
15703
+
15704
+ \item
15705
+ Otherwise, if the \grammarterm {qualified-id} \tcode {R::key_type}
15706
+ is valid and denotes a type:
15707
+ \begin {itemize }
15708
+ \item
15709
+ If the \grammarterm {qualified-id} \tcode {R::mapped_type}
15710
+ is valid and denotes a type,
15711
+ let \tcode {U} be \tcode {remove_cvref_t<ranges::range_reference_t<R>>}.
15712
+ If either \tcode {U} is a specialization of \tcode {pair} or
15713
+ \tcode {U} is a specialization of \tcode {tuple} and
15714
+ \tcode {tuple_size_v<U> == 2},
15715
+ \tcode {format_kind<R>} is \tcode {range_format::map}.
15716
+ \item
15717
+ Otherwise, \tcode {format_kind<R>} is \tcode {range_format::set}.
15718
+ \end {itemize }
15719
+
15720
+ \item
15721
+ Otherwise, \tcode {format_kind<R>} is \tcode {range_format::sequence}.
15722
+ \end {itemize }
15723
+
15724
+ \pnum
15725
+ \remarks
15726
+ Pursuant to \ref {namespace.std }, users may specialize \tcode {format_kind}
15727
+ for cv-unqualified program-defined types
15728
+ that model \tcode {ranges::\libconcept {input_range}}.
15729
+ Such specializations shall be usable in constant expressions\iref {expr.const }
15730
+ and have type \tcode {const range_format}.
15731
+ \end {itemdescr }
15732
+
15733
+ \rSec 3[format.range.formatter]{Class template \tcode {range_formatter}}
15734
+
15735
+ \indexlibraryglobal {range_formatter}%
15736
+ \begin {codeblock }
15737
+ namespace std {
15738
+ template<class T, class charT = char>
15739
+ requires @\libconcept {same_as}@<remove_cvref_t<T>, T> && @\libconcept {formattable}@<T, charT>
15740
+ class range_formatter {
15741
+ formatter<T, charT> @\exposid {underlying_}@; // \expos
15742
+ basic_string_view<charT> @\exposid {separator_}@ = @\exposid {STATICALLY-WIDEN}@<charT>(", "); // \expos
15743
+ basic_string_view<charT> @\exposid {opening-bracket_}@ = @\exposid {STATICALLY-WIDEN}@<charT>("["); // \expos
15744
+ basic_string_view<charT> @\exposid {closing-bracket_}@ = @\exposid {STATICALLY-WIDEN}@<charT>("]"); // \expos
15745
+
15746
+ public:
15747
+ constexpr void set_separator(basic_string_view<charT> sep);
15748
+ constexpr void set_brackets(basic_string_view<charT> opening,
15749
+ basic_string_view<charT> closing);
15750
+ constexpr formatter<T, charT>& underlying() { return @\exposid {underlying_}@; }
15751
+ constexpr const formatter<T, charT>& underlying() const { return @\exposid {underlying_}@; }
15752
+
15753
+ template<class ParseContext>
15754
+ constexpr typename ParseContext::iterator
15755
+ parse(ParseContext& ctx);
15756
+
15757
+ template<ranges::@\libconcept {input_range}@ R, class FormatContext>
15758
+ requires @\libconcept {formattable}@<ranges::range_reference_t<R>, charT> &&
15759
+ @\libconcept {same_as}@<remove_cvref_t<ranges::range_reference_t<R>>, T>
15760
+ typename FormatContext::iterator
15761
+ format(R&& r, FormatContext& ctx) const;
15762
+ };
15763
+ }
15764
+ \end {codeblock }
15672
15765
15673
15766
\pnum
15674
15767
The class template \tcode {range_formatter} is a utility
15768
15861
then there shall be
15769
15862
no \tcode {n} option and no \fmtgrammarterm {range-underlying-spec}.
15770
15863
15771
- \indexlibraryglobal {format_kind}
15772
- \begin {itemdecl }
15773
- template<ranges::@\libconcept {input_range}@ R>
15774
- requires @\libconcept {same_as}@<R, remove_cvref_t<R>>
15775
- constexpr range_format format_kind<R> = @\seebelow@ ;
15776
- \end {itemdecl }
15777
-
15778
- \begin {itemdescr }
15779
- \pnum
15780
- A program that instantiates the primary template of \tcode {format_kind}
15781
- is ill-formed.
15782
-
15783
- \pnum
15784
- For a type \tcode {R}, \tcode {format_kind<R>} is defined as follows:
15785
- \begin {itemize }
15786
- \item
15787
- If \tcode {\libconcept {same_as}<remove_cvref_t<ranges::range_reference_t<R>>, R>}
15788
- is \tcode {true},
15789
- \tcode {format_kind<R>} is \tcode {range_format::disabled}.
15790
- \begin {note }
15791
- This prevents constraint recursion for ranges whose
15792
- reference type is the same range type.
15793
- For example,
15794
- \tcode {std::filesystem::path} is a range of \tcode {std::filesystem::path}.
15795
- \end {note }
15796
-
15797
- \item
15798
- Otherwise, if the \grammarterm {qualified-id} \tcode {R::key_type}
15799
- is valid and denotes a type:
15800
- \begin {itemize }
15801
- \item
15802
- If the \grammarterm {qualified-id} \tcode {R::mapped_type}
15803
- is valid and denotes a type,
15804
- let \tcode {U} be \tcode {remove_cvref_t<ranges::range_reference_t<R>>}.
15805
- If either \tcode {U} is a specialization of \tcode {pair} or
15806
- \tcode {U} is a specialization of \tcode {tuple} and
15807
- \tcode {tuple_size_v<U> == 2},
15808
- \tcode {format_kind<R>} is \tcode {range_format::map}.
15809
- \item
15810
- Otherwise, \tcode {format_kind<R>} is \tcode {range_format::set}.
15811
- \end {itemize }
15812
-
15813
- \item
15814
- Otherwise, \tcode {format_kind<R>} is \tcode {range_format::sequence}.
15815
- \end {itemize }
15816
-
15817
- \pnum
15818
- \remarks
15819
- Pursuant to \ref {namespace.std }, users may specialize \tcode {format_kind}
15820
- for cv-unqualified program-defined types
15821
- that model \tcode {ranges::\libconcept {input_range}}.
15822
- Such specializations shall be usable in constant expressions\iref {expr.const }
15823
- and have type \tcode {const range_format}.
15824
- \end {itemdescr }
15825
-
15826
- \indexlibraryglobal {range_formatter}%
15827
- \begin {codeblock }
15828
- namespace std {
15829
- template<class T, class charT = char>
15830
- requires @\libconcept {same_as}@<remove_cvref_t<T>, T> && @\libconcept {formattable}@<T, charT>
15831
- class range_formatter {
15832
- formatter<T, charT> @\exposid {underlying_}@; // \expos
15833
- basic_string_view<charT> @\exposid {separator_}@ = @\exposid {STATICALLY-WIDEN}@<charT>(", "); // \expos
15834
- basic_string_view<charT> @\exposid {opening-bracket_}@ = @\exposid {STATICALLY-WIDEN}@<charT>("["); // \expos
15835
- basic_string_view<charT> @\exposid {closing-bracket_}@ = @\exposid {STATICALLY-WIDEN}@<charT>("]"); // \expos
15836
-
15837
- public:
15838
- constexpr void set_separator(basic_string_view<charT> sep);
15839
- constexpr void set_brackets(basic_string_view<charT> opening,
15840
- basic_string_view<charT> closing);
15841
- constexpr formatter<T, charT>& underlying() { return @\exposid {underlying_}@; }
15842
- constexpr const formatter<T, charT>& underlying() const { return @\exposid {underlying_}@; }
15843
-
15844
- template<class ParseContext>
15845
- constexpr typename ParseContext::iterator
15846
- parse(ParseContext& ctx);
15847
-
15848
- template<ranges::@\libconcept {input_range}@ R, class FormatContext>
15849
- requires @\libconcept {formattable}@<ranges::range_reference_t<R>, charT> &&
15850
- @\libconcept {same_as}@<remove_cvref_t<ranges::range_reference_t<R>>, T>
15851
- typename FormatContext::iterator
15852
- format(R&& r, FormatContext& ctx) const;
15853
- };
15854
- }
15855
- \end {codeblock }
15856
-
15857
15864
\indexlibrarymember {set_separator}{range_formatter}%
15858
15865
\begin {itemdecl }
15859
15866
constexpr void set_separator(basic_string_view<charT> sep);
15958
15965
An iterator past the end of the output range.
15959
15966
\end {itemdescr }
15960
15967
15968
+ \rSec 3[format.range.fmtdef]{Class template \tcode {\exposid {range-default-formatter}}}
15969
+
15961
15970
\indexlibraryglobal {\exposid {range-default-formatter}}%
15962
15971
\begin {codeblock }
15963
15972
namespace std {
16032
16041
Equivalent to: \tcode {return \exposid {underlying_}.format(elems, ctx);}
16033
16042
\end {itemdescr }
16034
16043
16044
+ \rSec 3[format.range.fmtmap]{Specialization of \tcode {\exposid {range-default-formatter}} for maps}
16045
+
16035
16046
\indexlibraryglobal {\exposid {range-default-formatter}}%
16036
16047
\begin {codeblock }
16037
16048
namespace std {
16109
16120
Equivalent to: \tcode {return \exposid {underlying_}.format(r, ctx);}
16110
16121
\end {itemdescr }
16111
16122
16123
+ \rSec 3[format.range.fmtset]{Specialization of \tcode {\exposid {range-default-formatter}} for sets}
16124
+
16112
16125
\indexlibraryglobal {\exposid {range-default-formatter}}%
16113
16126
\begin {codeblock }
16114
16127
namespace std {
@@ -16173,12 +16186,13 @@
16173
16186
Equivalent to: \tcode {return \exposid {underlying_}.format(r, ctx);}
16174
16187
\end {itemdescr }
16175
16188
16189
+ \rSec 3[format.range.fmtstr]{Specialization of \tcode {\exposid {range-default-formatter}} for strings}
16190
+
16176
16191
\indexlibraryglobal {\exposid {range-default-formatter}}%
16177
16192
\begin {codeblock }
16178
16193
namespace std {
16179
16194
template<range_format K, ranges::@\libconcept {input_range}@ R, class charT>
16180
- requires (K == range_format::string ||
16181
- K == range_format::debug_string)
16195
+ requires (K == range_format::string || K == range_format::debug_string)
16182
16196
struct @\exposid {range-default-formatter}@<K, R, charT> {
16183
16197
private:
16184
16198
formatter<basic_string<charT>, charT> @\exposid {underlying_}@; // \expos
0 commit comments