Skip to content

Commit 973f8f1

Browse files
authored
Merge 2022-07 LWG Motion 37
P2585R1 Improving default container formatting
2 parents 5fc53ce + a835920 commit 973f8f1

File tree

2 files changed

+350
-218
lines changed

2 files changed

+350
-218
lines changed

source/containers.tex

-153
Original file line numberDiff line numberDiff line change
@@ -13035,159 +13035,6 @@
1303513035
\end{codeblock}
1303613036
\end{itemdescr}
1303713037

13038-
\rSec1[assoc.format]{Associative formatting}
13039-
13040-
\pnum
13041-
For each of
13042-
\tcode{map},
13043-
\tcode{multimap},
13044-
\tcode{unordered_map},
13045-
\tcode{unordered_multimap},
13046-
\tcode{flat_map}, and
13047-
\tcode{flat_multimap},
13048-
the library provides the following formatter specialization
13049-
where \tcode{\placeholder{map-type}} is the name of the template:
13050-
13051-
\indexlibraryglobal{formatter}%
13052-
\begin{codeblock}
13053-
namespace std {
13054-
template<class charT, class Key, @\libconcept{formattable}@<charT> T, class... U>
13055-
requires @\libconcept{formattable}@<const Key, charT>
13056-
struct formatter<@\placeholder{map-type}@<Key, T, U...>, charT> {
13057-
private:
13058-
using @\exposid{maybe-const-map}@ = // \expos
13059-
@\exposid{fmt-maybe-const}@<@\placeholder{map-type}@<Key, T, U...>, charT>;
13060-
range_formatter<remove_cvref_t<ranges::range_reference_t<@\exposid{maybe-const-map}@>>,
13061-
charT> @\exposid{underlying_}@; // \expos
13062-
public:
13063-
constexpr formatter();
13064-
13065-
template<class ParseContext>
13066-
constexpr typename ParseContext::iterator
13067-
parse(ParseContext& ctx);
13068-
13069-
template<class FormatContext>
13070-
typename FormatContext::iterator
13071-
format(@\exposid{maybe-const-map}@& r, FormatContext& ctx) const;
13072-
};
13073-
}
13074-
\end{codeblock}
13075-
13076-
\indexlibraryctor{formatter}%
13077-
\begin{itemdecl}
13078-
constexpr formatter();
13079-
\end{itemdecl}
13080-
13081-
\begin{itemdescr}
13082-
\pnum
13083-
\effects
13084-
Equivalent to:
13085-
\begin{codeblock}
13086-
@\exposid{underlying_}@.set_brackets(@\exposid{STATICALLY-WIDEN}@<charT>("{"), @\exposid{STATICALLY-WIDEN}@<charT>("}"));
13087-
@\exposid{underlying_}@.underlying().set_brackets({}, {});
13088-
@\exposid{underlying_}@.underlying().set_separator(@\exposid{STATICALLY-WIDEN}@<charT>(": "));
13089-
\end{codeblock}
13090-
\end{itemdescr}
13091-
13092-
\indexlibrarymember{parse}{formatter}%
13093-
\begin{itemdecl}
13094-
template<class ParseContext>
13095-
constexpr typename ParseContext::iterator
13096-
parse(ParseContext& ctx);
13097-
\end{itemdecl}
13098-
13099-
\begin{itemdescr}
13100-
\pnum
13101-
\effects
13102-
Equivalent to: \tcode{return \exposid{underlying_}.parse(ctx);}
13103-
\end{itemdescr}
13104-
13105-
\indexlibrarymember{format}{formatter}%
13106-
\begin{itemdecl}
13107-
template<class FormatContext>
13108-
typename FormatContext::iterator
13109-
format(@\exposid{maybe-const-map}@& r, FormatContext& ctx) const;
13110-
\end{itemdecl}
13111-
13112-
\begin{itemdescr}
13113-
\pnum
13114-
\effects
13115-
Equivalent to: \tcode{return \exposid{underlying_}.format(r, ctx);}
13116-
\end{itemdescr}
13117-
13118-
\pnum
13119-
For each of
13120-
\tcode{set},
13121-
\tcode{multiset},
13122-
\tcode{unordered_set},
13123-
\tcode{unordered_multiset},
13124-
\tcode{flat_set}, and
13125-
\tcode{flat_multiset},
13126-
the library provides the following formatter specialization
13127-
where \tcode{\placeholder{set-type}} is the name of the template:
13128-
13129-
\indexlibraryglobal{formatter}%
13130-
\begin{codeblock}
13131-
namespace std {
13132-
template<class charT, class Key, class... U>
13133-
requires @\libconcept{formattable}@<const Key, charT>
13134-
struct formatter<@\placeholder{set-type}@<Key, U...>, charT> {
13135-
private:
13136-
range_formatter<Key, charT> @\exposid{underlying_}@; // \expos
13137-
public:
13138-
constexpr formatter();
13139-
13140-
template<class ParseContext>
13141-
constexpr typename ParseContext::iterator
13142-
parse(ParseContext& ctx);
13143-
13144-
template<class FormatContext>
13145-
typename FormatContext::iterator
13146-
format(const @\placeholder{set-type}@<Key, U...>& r, FormatContext& ctx) const;
13147-
};
13148-
}
13149-
\end{codeblock}
13150-
13151-
\indexlibraryctor{formatter}%
13152-
\begin{itemdecl}
13153-
constexpr formatter();
13154-
\end{itemdecl}
13155-
13156-
\begin{itemdescr}
13157-
\pnum
13158-
\effects
13159-
Equivalent to:
13160-
\begin{codeblock}
13161-
@\exposid{underlying_}@.set_brackets(@\exposid{STATICALLY-WIDEN}@<charT>("{"), @\exposid{STATICALLY-WIDEN}@<charT>("}"));
13162-
\end{codeblock}
13163-
\end{itemdescr}
13164-
13165-
\indexlibrarymember{parse}{formatter}%
13166-
\begin{itemdecl}
13167-
template<class ParseContext>
13168-
constexpr typename ParseContext::iterator
13169-
parse(ParseContext& ctx);
13170-
\end{itemdecl}
13171-
13172-
\begin{itemdescr}
13173-
\pnum
13174-
\effects
13175-
Equivalent to: \tcode{return \exposid{underlying_}.parse(ctx);}
13176-
\end{itemdescr}
13177-
13178-
\indexlibrarymember{format}{formatter}%
13179-
\begin{itemdecl}
13180-
template<class FormatContext>
13181-
typename FormatContext::iterator
13182-
format(const @\placeholder{set-type}@<Key, U...>& r, FormatContext& ctx) const;
13183-
\end{itemdecl}
13184-
13185-
\begin{itemdescr}
13186-
\pnum
13187-
\effects
13188-
Equivalent to: \tcode{return \exposid{underlying_}.format(r, ctx);}
13189-
\end{itemdescr}
13190-
1319113038
\rSec1[container.adaptors]{Container adaptors}
1319213039

1319313040
\rSec2[container.adaptors.general]{In general}

0 commit comments

Comments
 (0)