Skip to content

P2585R1 Improving default container formatting #5706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 0 additions & 153 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13035,159 +13035,6 @@
\end{codeblock}
\end{itemdescr}

\rSec1[assoc.format]{Associative formatting}

\pnum
For each of
\tcode{map},
\tcode{multimap},
\tcode{unordered_map},
\tcode{unordered_multimap},
\tcode{flat_map}, and
\tcode{flat_multimap},
the library provides the following formatter specialization
where \tcode{\placeholder{map-type}} is the name of the template:

\indexlibraryglobal{formatter}%
\begin{codeblock}
namespace std {
template<class charT, class Key, @\libconcept{formattable}@<charT> T, class... U>
requires @\libconcept{formattable}@<const Key, charT>
struct formatter<@\placeholder{map-type}@<Key, T, U...>, charT> {
private:
using @\exposid{maybe-const-map}@ = // \expos
@\exposid{fmt-maybe-const}@<@\placeholder{map-type}@<Key, T, U...>, charT>;
range_formatter<remove_cvref_t<ranges::range_reference_t<@\exposid{maybe-const-map}@>>,
charT> @\exposid{underlying_}@; // \expos
public:
constexpr formatter();

template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);

template<class FormatContext>
typename FormatContext::iterator
format(@\exposid{maybe-const-map}@& r, FormatContext& ctx) const;
};
}
\end{codeblock}

\indexlibraryctor{formatter}%
\begin{itemdecl}
constexpr formatter();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
@\exposid{underlying_}@.set_brackets(@\exposid{STATICALLY-WIDEN}@<charT>("{"), @\exposid{STATICALLY-WIDEN}@<charT>("}"));
@\exposid{underlying_}@.underlying().set_brackets({}, {});
@\exposid{underlying_}@.underlying().set_separator(@\exposid{STATICALLY-WIDEN}@<charT>(": "));
\end{codeblock}
\end{itemdescr}

\indexlibrarymember{parse}{formatter}%
\begin{itemdecl}
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return \exposid{underlying_}.parse(ctx);}
\end{itemdescr}

\indexlibrarymember{format}{formatter}%
\begin{itemdecl}
template<class FormatContext>
typename FormatContext::iterator
format(@\exposid{maybe-const-map}@& r, FormatContext& ctx) const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return \exposid{underlying_}.format(r, ctx);}
\end{itemdescr}

\pnum
For each of
\tcode{set},
\tcode{multiset},
\tcode{unordered_set},
\tcode{unordered_multiset},
\tcode{flat_set}, and
\tcode{flat_multiset},
the library provides the following formatter specialization
where \tcode{\placeholder{set-type}} is the name of the template:

\indexlibraryglobal{formatter}%
\begin{codeblock}
namespace std {
template<class charT, class Key, class... U>
requires @\libconcept{formattable}@<const Key, charT>
struct formatter<@\placeholder{set-type}@<Key, U...>, charT> {
private:
range_formatter<Key, charT> @\exposid{underlying_}@; // \expos
public:
constexpr formatter();

template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);

template<class FormatContext>
typename FormatContext::iterator
format(const @\placeholder{set-type}@<Key, U...>& r, FormatContext& ctx) const;
};
}
\end{codeblock}

\indexlibraryctor{formatter}%
\begin{itemdecl}
constexpr formatter();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
@\exposid{underlying_}@.set_brackets(@\exposid{STATICALLY-WIDEN}@<charT>("{"), @\exposid{STATICALLY-WIDEN}@<charT>("}"));
\end{codeblock}
\end{itemdescr}

\indexlibrarymember{parse}{formatter}%
\begin{itemdecl}
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return \exposid{underlying_}.parse(ctx);}
\end{itemdescr}

\indexlibrarymember{format}{formatter}%
\begin{itemdecl}
template<class FormatContext>
typename FormatContext::iterator
format(const @\placeholder{set-type}@<Key, U...>& r, FormatContext& ctx) const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return \exposid{underlying_}.format(r, ctx);}
\end{itemdescr}

\rSec1[container.adaptors]{Container adaptors}

\rSec2[container.adaptors.general]{In general}
Expand Down
Loading