range_formatter::formatSection: 28.5.7.2 [format.range.formatter] Status: Tentatively NAD Submitter: Hewill Kang Opened: 2025-04-18 Last modified: 2025-06-12
Priority: Not Prioritized
View all other issues in [format.range.formatter].
View all issues with Tentatively NAD status.
Discussion:
Currently, the signature of range_formatter::format is as follows:
template<ranges::input_range R, class FormatContext>
requires formattable<ranges::range_reference_t<R>, charT> &&
same_as<remove_cvref_t<ranges::range_reference_t<R>>, T>
typename FormatContext::iterator
format(R&& r, FormatContext& ctx) const;
which requires that the reference type of the range parameter must be formattable,
and such type must be exactly T after removing the cvref-qualifiers.
However, satisfying the latter always implies satisfying the former, as the range_formatter class
already requires that T must be formattable.
There is no need to perform a redundant check here.
[2025-06-12; Reflector poll]
Set status to Tentatively NAD. This is not redundant, it might check that
const T is formattable, which is not the same as checking that
T is formattable.
Proposed resolution:
This wording is relative to N5008.
Modify 28.5.7.2 [format.range.formatter] as indicated:
[…]namespace std { template<class T, class charT = char> requires same_as<remove_cvref_t<T>, T> && formattable<T, charT> class range_formatter { […] template<ranges::input_range R, class FormatContext> requiresformattable<ranges::range_reference_t<R>, charT> &&same_as<remove_cvref_t<ranges::range_reference_t<R>>, T> typename FormatContext::iterator format(R&& r, FormatContext& ctx) const; }; }template<ranges::input_range R, class FormatContext> requiresformattable<ranges::range_reference_t<R>, charT> &&same_as<remove_cvref_t<ranges::range_reference_t<R>>, T> typename FormatContext::iterator format(R&& r, FormatContext& ctx) const;-11- Effects: Writes the following into
ctx.out(), adjusted according to the range-format-spec: