This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
vformat_to
contains ill-formed formatted_size
callsSection: 28.5.5 [format.functions] Status: C++23 Submitter: Tim Song Opened: 2021-10-17 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [format.functions].
View all issues with C++23 status.
Discussion:
The specification of vformat_to
says that it formats "into the range
[out, out + N)
, where N
is formatted_size(fmt, args...)
for the
functions without a loc
parameter and formatted_size(loc, fmt, args...)
for the functions with a loc
parameter".
First, args
is a (w)format_args
, not a pack, so it doesn't make
sense to use ...
to expand it.
Second, fmt
is a (w)string_view
parameter, and it is never a
constant expression, and so the call is ill-formed after P2216 added
compile-time format string checking.
[2022-01-29; Reflector poll]
Set status to Tentatively Ready after six votes in favour during reflector poll.
[2022-02-10 Approved at February 2022 virtual plenary. Status changed: Tentatively Ready → WP.]
Proposed resolution:
This wording is relative to N4892.
Modify 28.5.5 [format.functions] as indicated:
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);-12- Let
-13- Constraints:charT
bedecltype(fmt)::value_type
.Out
satisfiesoutput_iterator<const charT&>
. -14- Preconditions:Out
modelsoutput_iterator<const charT&>
. -15- Effects: Places the character representation of formatting the arguments provided byargs
, formatted according to the specifications given infmt
, into the range[out, out + N)
, whereN
isthe number of characters in that character representation. If present,formatted_size(fmt, args...)
for the functions without aloc
parameter andformatted_size(loc, fmt, args...)
for the functions with aloc
parameterloc
is used for locale-specific formatting. -16- Returns:out + N
. -17- […]