Difference between revisions of "cpp/utility/format/ranges formatter/range default formatter sequence"
From cppreference.com
< cpp | utility | format | ranges formatter
Andreas Krug (Talk | contribs) m (fmt) |
m (fmt.) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|''range-default-formatter''{{small|<std::range_format::sequence>}}}} | {{cpp/title|''range-default-formatter''{{small|<std::range_format::sequence>}}}} | ||
{{cpp/utility/format/ranges_formatter/navbar}} | {{cpp/utility/format/ranges_formatter/navbar}} | ||
− | {{ddcl|header=format|since=c++23|notes={{mark expos}}| | + | {{ddcl|header=format|since=c++23|notes={{mark expos}}| |
template< ranges::input_range R, class CharT > | template< ranges::input_range R, class CharT > | ||
− | struct range-default-formatter<range_format::sequence, R, CharT>; | + | struct /*range-default-formatter*/<range_format::sequence, R, CharT>; |
}} | }} | ||
− | The class template {{ | + | The class template {{c/core|/*range-default-formatter*/}} for range types is specialized for formatting range as a sequence of elements if {{c|std::format_kind<R>}} is {{c|std::range_format::sequence}}. |
===Member types=== | ===Member types=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc hitem|Member | + | {{dsc hitem|Member|Definition}} |
− | {{dsc| | + | {{dsc expos mem type|private=yes|maybe-const-r|id=maybe-const-r|{{box/core|{{lsi|cpp/utility/format#fmt-maybe-const}}{{c/core|<R, CharT>}}}}}} |
{{dsc end}} | {{dsc end}} | ||
− | === | + | ===Data members=== |
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc hitem|Member | + | {{dsc hitem|Member|Definition}} |
− | {{dsc| | + | {{dsc expos mem obj|private=yes|underlying_|the underlying formatter of type: |
+ | {{box/core|{{c/core|std::range_formatter<std::remove_cvref_t<}}<br>{{nbspt|4}}{{c/core|ranges::range_reference_t<}}{{tti|maybe-const-r}}{{c/core|>>, CharT>}}}}}} | ||
{{dsc end}} | {{dsc end}} | ||
===Member functions=== | ===Member functions=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc mem ctor|nolink=true|notes={{mark implicit}}|constructs a {{ | + | {{dsc mem ctor|nolink=true|notes={{mark implicit}}|constructs a {{c/core|/*range-default-formatter*/}}}} |
{{dsc mem fun|set_separator|nolink=true|sets a specified separator for the range formatted result}} | {{dsc mem fun|set_separator|nolink=true|sets a specified separator for the range formatted result}} | ||
{{dsc mem fun|set_brackets|nolink=true|sets a specified opening and closing brackets for the range formatted result}} | {{dsc mem fun|set_brackets|nolink=true|sets a specified opening and closing brackets for the range formatted result}} | ||
Line 49: | Line 50: | ||
{{ddcl|1= | {{ddcl|1= | ||
template< class ParseContext > | template< class ParseContext > | ||
− | constexpr auto parse( ParseContext& ctx ) -> | + | constexpr auto parse( ParseContext& ctx ) -> ParseContext::iterator; |
}} | }} | ||
Equivalent to {{c|return underlying_.parse(ctx);}}. | Equivalent to {{c|return underlying_.parse(ctx);}}. | ||
− | Returns an iterator past the end of the | + | Returns an iterator past the end of the ''[[cpp/utility/format/range formatter#Range format specification|range-format-spec]]''. |
}} | }} | ||
Line 60: | Line 61: | ||
{{ddcl|1= | {{ddcl|1= | ||
template< class FormatContext > | template< class FormatContext > | ||
− | auto format( maybe-const-r& elems, FormatContext& ctx ) const | + | auto format( /*maybe-const-r*/& elems, FormatContext& ctx ) const -> FormatContext::iterator; |
− | + | ||
}} | }} | ||
Latest revision as of 13:31, 2 October 2024
Defined in header <format>
|
||
template< ranges::input_range R, class CharT > struct /*range-default-formatter*/<range_format::sequence, R, CharT>; |
(since C++23) (exposition only*) |
|
The class template /*range-default-formatter*/ for range types is specialized for formatting range as a sequence of elements if std::format_kind<R> is std::range_format::sequence.
[edit] Member types
Member | Definition |
maybe-const-r (private)
|
fmt-maybe-const <R, CharT>(exposition-only member type*) |
[edit] Data members
Member | Definition |
underlying_ (private)
|
the underlying formatter of type:
std::range_formatter<std::remove_cvref_t< |
[edit] Member functions
(constructor) (implicitly declared) |
constructs a /*range-default-formatter*/ (public member function) |
set_separator |
sets a specified separator for the range formatted result (public member function) |
set_brackets |
sets a specified opening and closing brackets for the range formatted result (public member function) |
parse |
parses the format specifier as specified by range-format-spec (public member function) |
format |
writes the range formatted output as specified by range-format-spec (public member function) |
std::range-default-formatter<std::range_format::sequence>::set_separator
constexpr void set_separator( std::basic_string_view<CharT> sep ) noexcept; |
||
Equivalent to a call to underlying_.set_separator(sep).
std::range-default-formatter<std::range_format::sequence>::set_brackets
constexpr void set_brackets( std::basic_string_view<CharT> opening, std::basic_string_view<CharT> closing ) noexcept; |
||
Equivalent to a call to underlying_.set_brackets(opening, closing).
std::range-default-formatter<std::range_format::sequence>::parse
template< class ParseContext > constexpr auto parse( ParseContext& ctx ) -> ParseContext::iterator; |
||
Equivalent to return underlying_.parse(ctx);.
Returns an iterator past the end of the range-format-spec.
std::range-default-formatter<std::range_format::sequence>::format
template< class FormatContext > auto format( /*maybe-const-r*/& elems, FormatContext& ctx ) const -> FormatContext::iterator; |
||
Equivalent to return underlying_.format(elems, ctx);.
Returns an iterator past the end of the output range.
[edit] See also
(C++20) |
defines formatting rules for a given type (class template) |
(C++23) |
class template that helps implementing std::formatter specializations for range types (class template) |