[format.syn]

# 28 Text processing library [[text]](./#text)

## 28.5 Formatting [[format]](format#syn)

### 28.5.1 Header <format> synopsis [format.syn]

[ð](#header:%3cformat%3e)

namespace std {// [[format.context]](format.context "28.5.6.7 Class template basic_­format_­context"), class template basic_format_contexttemplate<class Out, class charT> class basic_format_context; using format_context = basic_format_context<*unspecified*, char>; using wformat_context = basic_format_context<*unspecified*, wchar_t>; // [[format.args]](format.args "28.5.8.3 Class template basic_­format_­args"), class template basic_format_argstemplate<class Context> class basic_format_args; using format_args = basic_format_args<format_context>; using wformat_args = basic_format_args<wformat_context>; // [[format.fmt.string]](format.fmt.string "28.5.4 Class template basic_­format_­string"), class template basic_format_stringtemplate<class charT, class... Args>struct basic_format_string; template<class charT> struct *runtime-format-string* { // *exposition only*private: basic_string_view<charT> *str*; // *exposition only*public:*runtime-format-string*(basic_string_view<charT> s) noexcept : *str*(s) {}*runtime-format-string*(const *runtime-format-string*&) = delete; *runtime-format-string*& operator=(const *runtime-format-string*&) = delete; }; *runtime-format-string*<char> runtime_format(string_view fmt) noexcept { return fmt; }*runtime-format-string*<wchar_t> runtime_format(wstring_view fmt) noexcept { return fmt; }template<class... Args>using [format_string](#lib:format_string "28.5.1 Header <format> synopsis [format.syn]") = basic_format_string<char, type_identity_t<Args>...>; template<class... Args>using [wformat_string](#lib:wformat_string "28.5.1 Header <format> synopsis [format.syn]") = basic_format_string<wchar_t, type_identity_t<Args>...>; // [[format.functions]](format.functions "28.5.5 Formatting functions"), formatting functionstemplate<class... Args> string format(format_string<Args...> fmt, Args&&... args); template<class... Args> wstring format(wformat_string<Args...> fmt, Args&&... args); template<class... Args> string format(const locale& loc, format_string<Args...> fmt, Args&&... args); template<class... Args> wstring format(const locale& loc, wformat_string<Args...> fmt, Args&&... args);

 string vformat(string_view fmt, format_args args);
 wstring vformat(wstring_view fmt, wformat_args args);
 string vformat(const locale& loc, string_view fmt, format_args args);
 wstring vformat(const locale& loc, wstring_view fmt, wformat_args args); template<class Out, class... Args> Out format_to(Out out, format_string<Args...> fmt, Args&&... args); template<class Out, class... Args> Out format_to(Out out, wformat_string<Args...> fmt, Args&&... args); template<class Out, class... Args> Out format_to(Out out, const locale& loc, format_string<Args...> fmt, Args&&... args); template<class Out, class... Args> Out format_to(Out out, const locale& loc, wformat_string<Args...> fmt, Args&&... args); template<class Out> Out vformat_to(Out out, string_view fmt, format_args args); template<class Out> Out vformat_to(Out out, wstring_view fmt, wformat_args args); template<class Out> Out vformat_to(Out out, const locale& loc, string_view fmt, format_args args); template<class Out> Out vformat_to(Out out, const locale& loc, wstring_view fmt, wformat_args args); template<class Out> struct format_to_n_result { Out out;
 iter_difference_t<Out> size; }; template<class Out, class... Args> format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
 format_string<Args...> fmt, Args&&... args); template<class Out, class... Args> format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
 wformat_string<Args...> fmt, Args&&... args); template<class Out, class... Args> format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, const locale& loc, format_string<Args...> fmt,
 Args&&... args); template<class Out, class... Args> format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, const locale& loc, wformat_string<Args...> fmt,
 Args&&... args); template<class... Args> size_t formatted_size(format_string<Args...> fmt, Args&&... args); template<class... Args> size_t formatted_size(wformat_string<Args...> fmt, Args&&... args); template<class... Args> size_t formatted_size(const locale& loc, format_string<Args...> fmt, Args&&... args); template<class... Args> size_t formatted_size(const locale& loc, wformat_string<Args...> fmt, Args&&... args); // [[format.formatter]](format.formatter "28.5.6 Formatter"), formattertemplate<class T, class charT = char> struct formatter; // [[format.formatter.locking]](format.formatter.locking "28.5.6.2 Formatter locking"), formatter lockingtemplate<class T>constexpr bool enable_nonlocking_formatter_optimization = false; // [[format.formattable]](format.formattable "28.5.6.3 Concept formattable"), concept [formattable](format.formattable#concept:formattable "28.5.6.3 Concept formattable [format.formattable]")template<class T, class charT>concept formattable = *see below*; template<class R, class charT>concept [*const-formattable-range*](#concept:const-formattable-range "28.5.1 Header <format> synopsis [format.syn]") = // *exposition only* ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]")<const R> &&[formattable](format.formattable#concept:formattable "28.5.6.3 Concept formattable [format.formattable]")<ranges::range_reference_t<const R>, charT>; template<class R, class charT>using *fmt-maybe-const* = // *exposition only* conditional_t<[*const-formattable-range*](#concept:const-formattable-range "28.5.1 Header <format> synopsis [format.syn]")<R, charT>, const R, R>; // [[format.parse.ctx]](format.parse.ctx "28.5.6.6 Class template basic_­format_­parse_­context"), class template basic_format_parse_contexttemplate<class charT> class basic_format_parse_context; using format_parse_context = basic_format_parse_context<char>; using wformat_parse_context = basic_format_parse_context<wchar_t>; // [[format.range]](format.range "28.5.7 Formatting of ranges"), formatting of ranges// [[format.range.fmtkind]](format.range.fmtkind "28.5.7.1 Variable template format_­kind"), variable template format_kindenum class [range_format](#lib:range_format "28.5.1 Header <format> synopsis [format.syn]") {[disabled](#lib:range_format,disabled "28.5.1 Header <format> synopsis [format.syn]"), [map](#lib:range_format,map "28.5.1 Header <format> synopsis [format.syn]"), [set](#lib:range_format,set "28.5.1 Header <format> synopsis [format.syn]"), [sequence](#lib:range_format,sequence "28.5.1 Header <format> synopsis [format.syn]"), [string](#lib:range_format,string "28.5.1 Header <format> synopsis [format.syn]"), [debug_string](#lib:range_format,debug_string "28.5.1 Header <format> synopsis [format.syn]")}; template<class R>constexpr *unspecified* format_kind = *unspecified*; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R>requires [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<R, remove_cvref_t<R>>constexpr range_format format_kind<R> = *see below*; // [[format.range.formatter]](format.range.formatter "28.5.7.2 Class template range_­formatter"), class template range_formattertemplate<class T, class charT = char>requires [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<remove_cvref_t<T>, T> && [formattable](format.formattable#concept:formattable "28.5.6.3 Concept formattable [format.formattable]")<T, charT>class range_formatter; // [[format.range.fmtdef]](format.range.fmtdef "28.5.7.3 Class template range-default-formatter"), class template *range-default-formatter*template<range_format K, ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class charT>struct *range-default-formatter*; // *exposition only*// [[format.range.fmtmap]](format.range.fmtmap "28.5.7.4 Specialization of range-default-formatter for maps"), [[format.range.fmtset]](format.range.fmtset "28.5.7.5 Specialization of range-default-formatter for sets"), [[format.range.fmtstr]](format.range.fmtstr "28.5.7.6 Specialization of range-default-formatter for strings"), specializations for maps, sets, and stringstemplate<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class charT>requires (format_kind<R> != range_format::disabled) &&[formattable](format.formattable#concept:formattable "28.5.6.3 Concept formattable [format.formattable]")<ranges::range_reference_t<R>, charT>struct formatter<R, charT> : *range-default-formatter*<format_kind<R>, R, charT> { }; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R>requires (format_kind<R> != range_format::disabled)constexpr bool enable_nonlocking_formatter_optimization<R> = false; // [[format.arguments]](format.arguments "28.5.8 Arguments"), arguments// [[format.arg]](format.arg "28.5.8.1 Class template basic_­format_­arg"), class template basic_format_argtemplate<class Context> class basic_format_arg; // [[format.arg.store]](format.arg.store "28.5.8.2 Class template format-arg-store"), class template *format-arg-store*template<class Context, class... Args> class *format-arg-store*; // *exposition only*template<class Context = format_context, class... Args>*format-arg-store*<Context, Args...> make_format_args(Args&... fmt_args); template<class... Args>*format-arg-store*<wformat_context, Args...> make_wformat_args(Args&... args); // [[format.error]](format.error "28.5.10 Class format_­error"), class format_errorclass format_error;}

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L5906)

The class template format_to_n_result has the template parameters, data members, and special members specified above[.](#1.sentence-1)

It has no base classes or members other than those specified[.](#1.sentence-2)
