Skip to content

Commit d05a9b1

Browse files
committed
P2585R1 Improving default container formatting
1 parent 2dc630f commit d05a9b1

File tree

2 files changed

+291
-168
lines changed

2 files changed

+291
-168
lines changed

source/containers.tex

-149
Original file line numberDiff line numberDiff line change
@@ -13019,155 +13019,6 @@
1301913019
\end{codeblock}
1302013020
\end{itemdescr}
1302113021

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

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

0 commit comments

Comments
 (0)