Option | Meaning | |
< | ||
> | ||
^ | Forces the formatted argument to be centered within the field
by inserting
fill characters before and
fill characters after the formatted argument, where
n is the padding width. |
Option | Meaning | |
+ | ||
- | Indicates that a sign should be used for
negative numbers and negative zero only (this is the default behavior). | |
space | Indicates that a leading space should be used for
non-negative numbers other than negative zero, and
a minus sign for negative numbers and negative zero. |
Type | Meaning | |
none, s | Copies the string to the output. | |
? | Copies the escaped string ([format.string.escaped]) to the output. |
Type | Meaning | |
b | ||
B | ||
c | ||
d | to_chars(first, last, value). | |
o | ||
x | ||
X | ||
none |
Type | Meaning | |
a | If precision is specified, equivalent to
to_chars(first, last, value, chars_format::hex, precision)
where precision is the specified formatting precision; equivalent to
to_chars(first, last, value, chars_format::hex)
otherwise. | |
A | The same as a, except that
it uses uppercase letters for digits above 9 and
P to indicate the exponent. | |
e | Equivalent to
to_chars(first, last, value, chars_format::scientific, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
E | ||
f, F | Equivalent to
to_chars(first, last, value, chars_format::fixed, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
g | Equivalent to
to_chars(first, last, value, chars_format::general, precision)
where precision is the specified formatting precision,
or 6 if precision is not specified. | |
G | ||
none | If precision is specified, equivalent to
to_chars(first, last, value, chars_format::general, precision)
where precision is the specified formatting precision; equivalent to
to_chars(first, last, value)
otherwise. |
Type | Meaning | |
none, p | If uintptr_t is defined,
to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16)
with the prefix 0x inserted immediately before the output of to_chars;
otherwise, implementation-defined. |
template<class T> consteval basic_format_string(const T& s);
template<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, 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);
Expression | Return type | Requirement | |
g.parse(pc) | PC::iterator | Parses format-spec ([format.string])
for type T
in the range [pc.begin(), pc.end())
until the first unmatched character.
Stores the parsed format specifiers in *this and
returns an iterator past the end of the parsed range. | |
f.format(u, fc) | FC::iterator | Formats u according to the specifiers stored in *this,
writes the output to fc.out(), and
returns an iterator past the end of the output range. The output shall only depend on
u,
fc.locale(),
fc.arg(n) for any value n of type size_t,
and the range [pc.begin(), pc.end())
from the last call to f.parse(pc). |
Expression | Return type | Requirement | |
f.format(t, fc) | FC::iterator | Formats t according to the specifiers stored in *this,
writes the output to fc.out(), and
returns an iterator past the end of the output range. The output shall only depend on
t,
fc.locale(),
fc.arg(n) for any value n of type size_t,
and the range [pc.begin(), pc.end())
from the last call to f.parse(pc). | |
f.format(u, fc) | FC::iterator | As above, but does not modify u. |
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
size_t num_args = 0) noexcept;
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr void advance_to(const_iterator it);
constexpr size_t next_arg_id();
constexpr void check_arg_id(size_t id);
basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
std::locale locale();
iterator out();
void advance_to(iterator it);
template<ranges::input_range R>
requires same_as<R, remove_cvref_t<R>>
constexpr range_format format_kind<R> = see below;
Option | Requirements | Meaning | |
m | T shall be
either a specialization of pair or a specialization of tuple
such that tuple_size_v<T> is 2. | Indicates that
the opening bracket should be "{",
the closing bracket should be "}",
the separator should be ", ", and
each range element should be formatted as if
m were specified for its tuple-type. | |
s | Indicates that the range should be formatted as a string. | ||
?s | Indicates that the range should be formatted as
an escaped string ([format.string.escaped]). |
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<ranges::input_range R, class FormatContext>
requires formattable<ranges::range_reference_t<R>, charT> &&
same_as<remove_cvref_t<ranges::range_reference_t<R>>, T>
typename FormatContext::iterator
format(R&& r, FormatContext& ctx) const;
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-r& elems, FormatContext& ctx) const;
constexpr range-default-formatter();
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-map& r, FormatContext& ctx) const;
constexpr range-default-formatter();
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(maybe-const-set& r, FormatContext& ctx) const;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(see below& r, FormatContext& ctx) const;
basic_format_arg() noexcept;
template<class T> explicit basic_format_arg(T& v) noexcept;
explicit operator bool() const noexcept;
template<class T> explicit handle(T& val) noexcept;
void format(basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx) const;
template<class Visitor, class Context>
decltype(auto) visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg);
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);
basic_format_args() noexcept;
template<class... Args>
basic_format_args(const format-arg-store<Context, Args...>& store) noexcept;
basic_format_arg<Context> get(size_t i) const noexcept;
constexpr void set_separator(basic_string_view<charT> sep) noexcept;
constexpr void set_brackets(basic_string_view<charT> opening,
basic_string_view<charT> closing) noexcept;
template<class ParseContext>
constexpr typename ParseContext::iterator
parse(ParseContext& ctx);
template<class FormatContext>
typename FormatContext::iterator
format(see below& elems, FormatContext& ctx) const;
format_error(const string& what_arg);
format_error(const char* what_arg);