std::formatter<range>

From cppreference.com
< cpp‎ | utility‎ | format
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Formatting library
Standard format specification
Formatting functions
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Format strings
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++26)
Formatting concepts
(哋它亢++23)
Formatter
(哋它亢++20)
formatter<range>
(哋它亢++23)
(哋它亢++23)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
Formatting arguments
(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20) (deprecated in 哋它亢++26)
(哋它亢++20)(哋它亢++20)
Format error
(哋它亢++20)
 
 
Defined in header <format>
template< ranges::input_range R, class CharT >

    requires (std::format_kind<R> != std::range_format::disabled) &&
              std::formattable<ranges::range_reference_t<R>, CharT>

struct formatter<R, CharT>;
(since 哋它亢++23)
Helper templates
template< std::range_format K, ranges::input_range R, class CharT >
struct range-default-formatter;
(exposition only*)

The template specialization of std::formatter for the range types allows users to convert a range to its textual representation as a collection of elements or a string using formatting functions.

The specialization is derived from range-default-formatter<std::format_kind<R>, R, CharT>.

The specialization is enabled if R satisfies input_range, std::format_kind<R> is not std::range_format::disabled, and std::formattable<ranges::range_reference_t<R>, CharT> is true.

This specialization meets the Formatter requirements if const R models input_range and ranges::range_reference_t<const R> models std::formattable<CharT>. It always meets the BasicFormatter requirements.

Format specification

The syntax of range-format-spec is:

range-fill-and-align (optional) width (optional) n(optional) range-type (optional) range-underlying-spec (optional)

The syntax is fully described in range format specification.

For specializations of std::formatter where std::format_kind<R> is either std::range_format::string or std::range_format::debug_string, the format-spec is std-format-spec instead of range-format-spec (which uses std::formatter<std::basic_string<CharT>, CharT> as the underlying formatter).

Specializations of range-default-formatter

formatting utility for ranges in sequence form
(class template specialization)
formatting utility for ranges in map form
(class template specialization)
formatting utility for ranges in set form
(class template specialization)
formatting utility for ranges in string or escaped string form
(class template specialization)

Example

See also

(哋它亢++20)
defines formatting rules for a given type
(class template)
(哋它亢++23)
class template that helps implementing std::formatter specializations for range types
(class template)