= ranges::input_range<const _Rg>
&& formattable<ranges::range_reference_t<const _Rg>, _CharT>;
+ // _Rg& and const _Rg& are both formattable and use same formatter
+ // specialization for their references.
+ template<typename _Rg, typename _CharT>
+ concept __simply_formattable_range
+ = __const_formattable_range<_Rg, _CharT>
+ && same_as<remove_cvref_t<ranges::range_reference_t<_Rg>>,
+ remove_cvref_t<ranges::range_reference_t<const _Rg>>>;
+
template<typename _Rg, typename _CharT>
using __maybe_const_range
= __conditional_t<__const_formattable_range<_Rg, _CharT>, const _Rg, _Rg>;
format(_Rg&& __rg, basic_format_context<_Out, _CharT>& __fc) const
{
using _Range = remove_reference_t<_Rg>;
- if constexpr (__format::__const_formattable_range<_Range, _CharT>)
- {
- using _CRef = ranges::range_reference_t<const _Range>;
- if constexpr (same_as<remove_cvref_t<_CRef>, _Tp>)
- return _M_format<const _Range>(__rg, __fc);
- }
- return _M_format(__rg, __fc);
+ if constexpr (__format::__simply_formattable_range<_Range, _CharT>)
+ return _M_format<const _Range>(__rg, __fc);
+ else
+ return _M_format(__rg, __fc);
}
private: