This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
3246. What are the constraints on the template parameter ofbasic_format_arg
?
Section: 28.5.8.1 [format.arg] Status: C++20 Submitter: Richard Smith Opened: 2019-08-01 Last modified: 2021-02-25
Priority: 0
View all other issues in [format.arg].
View all issues with C++20 status.
Discussion:
In P0645R10 20.?.5.1/ we find:
Constraints:
typename Context::template formatter_type<T>
is enabled.
… which doesn't mean anything, because that is an arbitrary type. Presumably the intent is that that type will always be a specialization of formatter, but there appear to be no constraints whatsoever on the Context
template parameter, so there seems to be no requirement that that is the case.
basic_format_arg
place some constraints on its Context
template parameter? E.g., should it be required to be a specialization of basic_format_context
? Victor Zverovich: The intent here is to allow different context types provide their own formatter extension types. The default formatter context and extension are basic_format_context
and formatter respectively, but it's possible to have other. For example, in the fmt
library there is a formatter context that supports printf
formatting for legacy code. It cannot use the default formatter specializations because of the different syntax (%...
vs {...})
. Richard Smith: In either case, the specification here seems to be missing the rules for what is a valid Context
parameter. I'm happy to editorially change "is enabled" to "is an enabled specialization of formatter", since there's nothing else that this could mean, but we still need a wording fix for the broader issue here. Here's what I have so far for this wording:
Constraints: The template specialization
typename Context::template formatter_type<T>
is an enabled specialization of formatter ([formatter.requirements]).
Tim Song:
I think what we actually want here is "typename Context::template formatter_type<T>
meets the Formatter requirements".
[2019-08-17 Issue Prioritization]
Status to Tentatively Ready and priority to 0 after six positive votes on the reflector.
Proposed resolution:
This wording is relative to N4830.
Modify 28.5.8.1 [format.arg] as indicated:
template<class T> explicit basic_format_arg(const T& v) noexcept;-4- Constraints: The template specialization
typename Context::template formatter_type<T>is an enabled specialization of
formatter
meets the Formatter requirements (28.5.6 [format.formatter]). The extent to which an implementation determines that the specialization is enabled meets the Formatter requirements is unspecified, except that as a minimum the expressiontypename Context::template formatter_type<T>() .format(declval<const T&>(), declval<Context&>())shall be well-formed when treated as an unevaluated operand.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4