std::range-...t-formatter,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

Hii bestie!! Welcome to the std::range-default-formatter, - std::range-default-formatter, page from the C++ Standard Libary manual β€” page handle std::range-...t-formatter,(3). Yes, that's the whole name up top, and we're folding the manual name in here instead of copying the header line πŸ’….


✨ Synopsis ✨

Okay so first thing: this is Defined in header <format>, and it's tagged (since C++23).

Here's the signature, bestie:

template< std::range_format K, ranges::input_range R, class
CharT >
    requires (K == std::range_format::string || K ==
              (exposition only*)
              std::range_format::debug_string)

struct range-default-formatter<K, R, CharT>;

The class template range-default-formatter for range types is specialized for formatting range as a string or an escaped string if std::format_kind<R> is either std::range_format::string or std::range_format::debug_string.


πŸŽ€ Member objects πŸŽ€

There's one sneaky member object:

  • Member name: underlying_ (private) β€” Definition: the underlying formatter of type std::formatter<std::basic_string<CharT>, CharT> (exposition-only member object*).

🫢 Member functions 🫢

  • constructor (implicitly declared) (public member function) β€” constructs a range-default-formatter.
  • parse (public member function) β€” parses the format specifier as specified by std-format-spec.
  • format (public member function) β€” writes the formatted output as specified by std-format-spec.

🧚 std::range-default-formatter<std::range_format::string>::parse and std::range-default-formatter<std::range_format::debug_string>::parse

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

Equivalent to:

auto i = underlying_.parse(ctx);
if constexpr (K == std::range_format::debug_string)
    underlying_.set_debug_format();
return i;

Returns an iterator past the end of the std-format-spec.

πŸ¦‹ std::range-default-formatter<std::range_format::string>::format and std::range-default-formatter<std::range_format::debug_string>::format

template< class FormatContext >
auto format( /* see below */& r, FormatContext& ctx ) const ->
FormatContext::iterator;

If ranges::input_range<const R> is true, the type of r is const R&. Otherwise, the type is R&.

Let s be a std::basic_string<CharT> as if by constructing s with std::basic_string<CharT>(std::from_range, r) such that ranges::equal(s, r) is true.

Equivalent to return underlying_.format(s, ctx);.

Returns an iterator past the end of the output range.


🌈 See also 🌈

  • formatter β€” defines formatting rules for a given type (C++20) (class template).
  • range_formatter β€” class template that helps implementing std::formatter specializations for range types (C++23) (class template).

Alright bestie, that's the whole page! Source/version http://cppreference.com Β· date 2024.06.10 Β· page std::range-...t-formatter,(3). Now go format something cute πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from