Created on 2022-10-28.00:00:00 last changed 22 months ago
Proposed resolution:
This wording is relative to N4917.
Modify [format.syn] as indicated:
[…] // [format.formatter], formatter template<class T, class charT = char> struct formatter; // [format.formattable], concept formattable template<class T, class charT = char> concept formattable = see below; […]
Modify [format.formattable] as indicated:
[Drafting note: This repeats the default template argument already shown in the synopsis, which would not be valid in C++ code. That is consistent with our presentation style though, as this is not C++ code, it's a specification. See e.g. indirect_strict_weak_order and subrange.]
-1- Let fmt-iter-for<charT> be an unspecified type that models output_iterator<const charT&> ([iterator.concept.output]).
template<class T, class charT = char> concept formattable = semiregular<formatter<remove_cvref_t<T>, charT>> && requires(formatter<remove_cvref_t<T>, charT> f, const formatter<remove_cvref_t<T>, charT> cf, T t, basic_format_context<fmt-iter-for<charT>, charT> fc, basic_format_parse_context<charT> pc) { { f.parse(pc) } -> same_as<basic_format_parse_context<charT>::iterator>; { cf.format(t, fc) } -> same_as<fmt-iter-for<charT>>; };
[ 2023-01-24 LEWG electronic poll; weak consensus to reject the propsed change. ]
[ 2022-11-30 LWG telecon. Status changed: Tentatively NAD → NAD. ]
[ 2022-11-30; Reflector poll ]
Set status to "Tentatively NAD" after ten votes in reflector poll.
[ 2022-11-01; Reflector poll ]
Set priority to 2 after reflector poll. Two votes for NAD, the convenience makes it easier to misuse.
For many uses of <format> there's no need to explicitly mention the output type as char. There are either typedefs for char specializations (format_context, format_parse_context, format_args, etc.) or a default template argument (formatter, range_formatter). But for the new formattable concept you always need to specify the character type:
static_assert( std::formattable<int> ); // ill-formed
static_assert( std::formattable<int, char> ); // OK
Should the concept have a default template argument for the second parameter, to make it easier to check whether something is formattable as char?
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-01-24 10:14:05 | admin | set | messages: + msg13214 |
2022-11-30 17:59:24 | admin | set | messages: + msg13144 |
2022-11-30 09:50:07 | admin | set | messages: + msg13122 |
2022-11-30 09:50:07 | admin | set | status: new -> nad |
2022-11-01 17:49:23 | admin | set | messages: + msg12917 |
2022-10-29 12:43:40 | admin | set | messages: + msg12899 |
2022-10-28 00:00:00 | admin | create |