Created on 2022-05-17.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4910.
Modify [format.formatter.spec] as indicated:
-2- Let charT be either char or wchar_t. Each specialization of formatter is either enabled or disabled, as described below. Each header that declares the template formatter provides the following enabled specializations:
(2.1) — The specializations […]
(2.2) — For each charT, the string type specializations
template<> struct formatter<charT*, charT>; template<> struct formatter<const charT*, charT>; template<size_t N> struct formatter<charT[N], charT>; template<size_t N> struct formatter<const charT[N], charT>; template<class traits, class Allocator> struct formatter<basic_string<charT, traits, Allocator>, charT>; template<class traits> struct formatter<basic_string_view<charT, traits>, charT>;(2.3) — […]
(2.4) — […]
[ 2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP. ]
[ 2022-07-15; LWG telecon: move to Ready ]
[ 2022-06-21; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
The wording in [format.functions]/20 and [format.functions]/25 both contain
formatter<remove_cvref_t<Ti>, charT> meets the BasicFormatter requirements ([formatter.requirements]) for each Ti in Args.
The issue is that remove_cvref_t<const charT[N]> becomes charT[N]. [format.formatter.spec]/2.2 requires a specialization for
template<size_t N> struct formatter<const charT[N], charT>;
but there's no requirement to provide
template<size_t N> struct formatter<charT[N], charT>;
There's no wording preventing library vendors from providing additional specializations. So it's possible to implement the current specification but the indirect requirement is odd. I noticed this while implementing a formattable concept. The concept is based on the formattable concept of P2286 "Formatting Ranges" (This paper is targeting C++23.)
It could be argued that the specializationtemplate<size_t N> struct formatter<const charT[N], charT>
is not needed and should be removed from the Standard. This will be an API break. Vendors can decide to keep the no longer required specialization as an extension; which would lead to implementation divergence. Microsoft is already shipping this specialization as stable and Victor doesn't like the removal too.
Therefore I only propose to add the required formatter specialization.History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2022-07-25 20:32:58 | admin | set | messages: + msg12643 |
2022-07-25 20:32:58 | admin | set | status: ready -> wp |
2022-07-25 20:28:19 | admin | set | messages: + msg12617 |
2022-06-21 11:47:28 | admin | set | messages: + msg12514 |
2022-06-21 11:47:28 | admin | set | status: new -> ready |
2022-05-21 12:26:11 | admin | set | messages: + msg12474 |
2022-05-17 00:00:00 | admin | create |