This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
range_formatter::format
Section: 28.5.7.2 [format.range.formatter] Status: New Submitter: Hewill Kang Opened: 2025-04-18 Last modified: 2025-04-21
Priority: Not Prioritized
View all other issues in [format.range.formatter].
View all issues with New 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.
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: