Created on 2022-05-17.00:00:00 last changed 3 days ago
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 specializationstemplate<> struct formatter<charT*, charT>; template<> struct formatter<const charT*, 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-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 specialization
template<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.
|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|