Localization library | |||||||||||||||||||||||||
Regular expressions library(C++11) | |||||||||||||||||||||||||
Formatting library(C++20) | |||||||||||||||||||||||||
Null-terminated sequence utilities | |||||||||||||||||||||||||
Byte strings | |||||||||||||||||||||||||
Multibyte strings | |||||||||||||||||||||||||
Wide strings | |||||||||||||||||||||||||
Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
Text encoding identifications | |||||||||||||||||||||||||
|
Standard format specification | ||||
Formatting functions | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
Format strings | ||||
(C++20)(C++20)(C++20) | ||||
(C++26) | ||||
Formatting concepts | ||||
(C++23) | ||||
Formatter | ||||
(C++20) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++20)(C++20)(C++20) | ||||
basic_format_contextformat_contextwformat_context (C++20)(C++20)(C++20) | ||||
(C++23) | ||||
(C++23) | ||||
Formatting arguments | ||||
(C++20) | ||||
(C++20) | ||||
(C++20)(C++20)(C++20) | ||||
(C++20)(deprecated in C++26) | ||||
(C++20)(C++20) | ||||
Format error | ||||
(C++20) |
Defined in header <format> | ||
template<class OutputIt,class CharT> class basic_format_context; | (1) | (since C++20) |
using format_context= basic_format_context</* unspecified */,char>; | (2) | (since C++20) |
using wformat_context= basic_format_context</* unspecified */,wchar_t>; | (3) | (since C++20) |
Provides access to formatting state consisting of the formatting arguments and the output iterator.
The behavior is undefined ifOutputIt
does not modelstd::output_iterator<const CharT&>.
A program that declares an explicit or partial specialization ofstd::basic_format_context
is ill-formed, no diagnostic required.
std::basic_format_context
objects can only be created by the implementation. User codes are only allowed to modify the format context via theformat
function ofstd::formatter specializations.
Contents |
Type | Definition |
iterator | OutputIt |
char_type | CharT |
Type | Definition |
formatter_type<T> | std::formatter<T, CharT> |
(constructor) [deleted] | basic_format_context cannot be constructed by user code(public member function) |
operator= [deleted] | basic_format_context is not assignable(public member function) |
arg | returns the argument at the given index (public member function) |
locale | returns the locale used for locale-specific formatting (public member function) |
out | returns the iterator to output buffer (public member function) |
advance_to | advances the output iterator to the given position (public member function) |
std::basic_format_arg<basic_format_context> arg(std::size_t id)const; | ||
Returns astd::basic_format_arg
holding theid
-th argument inargs
, whereargs
is the parameter pack orstd::basic_format_args
object passed to the formatting function.
Ifid
is not less than the number of formatting arguments, returns a default-constructedstd::basic_format_arg
(holding astd::monostate object).
std::locale locale(); | ||
Returns the locale passed to the formatting function, or a default-constructedstd::locale if the formatting function does not take a locale.
iterator out(); | ||
Returns the iterator to the output buffer. The result is move-constructed from the stored iterator.
void advance_to( iterator it); | ||
Move assignsit
to the stored output iterator. After a call toadvance_to
, the next call toout()
will return an iterator with the value thatit
had before the assignment.
This section is incomplete Reason: no example |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3567 | C++20 | basic_format_context does not work move-only iterator types | made to move iterators |
LWG 3975 | C++20 | user specialization ofbasic_format_context was allowed | disallowed |
LWG 4061 | C++20 | basic_format_context was constructible and assignable by user code | made neither constructible nor assignable |