Created on 2021-03-31.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [format.functions] as indicated:
template<class Out, class... Args> Out format_to(Out out, string_view fmt, const Args&... args); template<class Out, class... Args> Out format_to(Out out, wstring_view fmt, const Args&... args);-8- Effects: Equivalent to:
using context = basic_format_context<Out, decltype(fmt)::value_type>; return vformat_to(std::move(out), fmt, make_format_args<context>(args...));template<class Out, class... Args> Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); template<class Out, class... Args> Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);-9- Effects: Equivalent to:
using context = basic_format_context<Out, decltype(fmt)::value_type>; return vformat_to(std::move(out), loc, fmt, make_format_args<context>(args...));
[ 2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-04-20; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[format.functions] specifies the overloads of format_to as:
template<class Out, class... Args> Out format_to(Out out, string_view fmt, const Args&... args); template<class Out, class... Args> Out format_to(Out out, wstring_view fmt, const Args&... args);-8- Effects: Equivalent to:
using context = basic_format_context<Out, decltype(fmt)::value_type>; return vformat_to(out, fmt, make_format_args<context>(args...));template<class Out, class... Args> Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); template<class Out, class... Args> Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); Out format_to(Out out, wstring_view fmt, const Args&... args);-9- Effects: Equivalent to:
using context = basic_format_context<Out, decltype(fmt)::value_type>; return vformat_to(out, loc, fmt, make_format_args<context>(args...));
but the overloads of vformat_to take their first argument by value (from the same subclause):
template<class Out> Out vformat_to(Out out, string_view fmt, format_args_t<type_identity_t<Out>, char> args); template<class Out> Out vformat_to(Out out, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> args); template<class Out> Out vformat_to(Out out, const locale& loc, string_view fmt, format_args_t<type_identity_t<Out>, char> args); template<class Out> Out vformat_to(Out out, const locale& loc, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> args);-10- Let charT be decltype(fmt)::value_type.
-11- Constraints: Out satisfies output_iterator<const charT&>. -12- Preconditions: Out models output_iterator<const charT&>.
and require its type to model output_iterator<const charT&>. output_iterator<T, U> refines input_or_output_iterator<T> which refines movable<T>, but it notably does not refine copyable<T>. Consequently, the "Equivalent to" code for the format_to overloads is copying an iterator that could be move-only. I suspect it is not the intent that calls to format_to with move-only iterators be ill-formed, but that it was simply an oversight that this wording needs updating to be consistent with the change to allow move-only single-pass iterators in C++20.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-06-07 16:58:04 | admin | set | messages: + msg11904 |
2021-06-07 16:58:04 | admin | set | status: voting -> wp |
2021-05-26 21:11:22 | admin | set | status: ready -> voting |
2021-04-20 20:22:19 | admin | set | messages: + msg11768 |
2021-04-20 20:22:19 | admin | set | status: new -> ready |
2021-04-04 13:18:04 | admin | set | messages: + msg11757 |
2021-03-31 00:00:00 | admin | create |