GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • formattable

This view

  • Original page
  • New address

GeezerVison is showing timsong-cpp.github.io — [format.tuple]

28 Text processing library [text]

28.5 Formatting [format]

28.5.9 Tuple formatter [format.tuple]

1
#
For each of pair and tuple, the library provides the following formatter specialization where pair-or-tuple is the name of the template:
🔗
namespace std { template<class charT, formattable<charT>... Ts> struct formatter<pair-or-tuple<Ts...>, charT> { private: tuple<formatter<remove_cvref_t<Ts>, charT>...> underlying_; // exposition only basic_string_view<charT> separator_ = STATICALLY-WIDEN<charT>(", "); // exposition only basic_string_view<charT> opening-bracket_ = STATICALLY-WIDEN<charT>("("); // exposition only basic_string_view<charT> closing-bracket_ = STATICALLY-WIDEN<charT>(")"); // exposition only public: constexpr void set_separator(basic_string_view<charT> sep) noexcept; constexpr void set_brackets(basic_string_view<charT> opening, basic_string_view<charT> closing) noexcept; template<class ParseContext> constexpr typename ParseContext::iterator parse(ParseContext& ctx); template<class FormatContext> constexpr typename FormatContext::iterator format(see below& elems, FormatContext& ctx) const; }; template<class... Ts> constexpr bool enable_nonlocking_formatter_optimization<pair-or-tuple<Ts...>> = (enable_nonlocking_formatter_optimization<remove_cvref_t<Ts>> && ...); }
2
#
The parse member functions of these formatters interpret the format specification as a tuple-format-spec according to the following syntax:
tuple-format-spec :
tuple-fill-and-alignopt widthopt tuple-typeopt
tuple-fill-and-align :
tuple-fillopt align
tuple-fill :
any character other than { or } or :
tuple-type :
m
n
3
#
The tuple-fill-and-align is interpreted the same way as a fill-and-align ([format.string.std]).
The productions align and width are described in [format.string].
4
#
The tuple-type specifier changes the way a pair or tuple is formatted, with certain options only valid with certain argument types.
The meaning of the various type options is as specified in Table 116.
Table 116 — Meaning of tuple-type options [tab:formatter.tuple.type]
🔗
Option
Requirements
Meaning
🔗
m
sizeof...(Ts) == 2
Equivalent to: set_separator(STATICALLY-WIDEN<charT>(": ")); set_brackets({}, {});
🔗
n
none
Equivalent to: set_brackets({}, {});
🔗
none
none
No effects
🔗
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
5
#
Effects: Equivalent to: separator_ = sep;
🔗
constexpr void set_brackets(basic_string_view<charT> opening, basic_string_view<charT> closing) noexcept;
6
#
Effects: Equivalent to: opening-bracket_ = opening; closing-bracket_ = closing;
🔗
template<class ParseContext> constexpr typename ParseContext::iterator parse(ParseContext& ctx);
7
#
Effects: Parses the format specifiers as a tuple-format-spec and stores the parsed specifiers in *this.
The values of opening-bracket_, closing-bracket_, and separator_ are modified if and only if required by the tuple-type, if present.
For each element e in underlying_, calls e.parse(ctx) to parse an empty format-spec and, if e.set_debug_format() is a valid expression, calls e.set_debug_format().
8
#
Returns: An iterator past the end of the tuple-format-spec.
🔗
template<class FormatContext> constexpr typename FormatContext::iterator format(see below& elems, FormatContext& ctx) const;
9
#
The type of elems is:
  • (9.1)
    If (formattable<const Ts, charT> && ...) is true, const pair-or-tuple<Ts...>&.
  • (9.2)
    Otherwise pair-or-tuple<Ts...>&.
10
#
Effects: Writes the following into ctx.out(), adjusted according to the tuple-format-spec:
  • (10.1)
    opening-bracket_,
  • (10.2)
    for each index I in the [0, sizeof...(Ts)):
    • (10.2.1)
      if I != 0, separator_,
    • (10.2.2)
      the result of writing get<I>(elems) via get<I>(underlying_), and
  • (10.3)
    closing-bracket_.
11
#
Returns: An iterator past the end of the output range.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.