diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h --- a/libcxx/include/__chrono/formatter.h +++ b/libcxx/include/__chrono/formatter.h @@ -485,12 +485,12 @@ static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); } -template +template _LIBCPP_HIDE_FROM_ABI auto __format_chrono(const _Tp& __value, - auto& __ctx, + _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, - basic_string_view<_CharT> __chrono_specs) -> decltype(__ctx.out()) { + basic_string_view<_CharT> __chrono_specs) { basic_stringstream<_CharT> __sstr; // [time.format]/2 // 2.1 - the "C" locale if the L option is not present in chrono-format-spec, otherwise @@ -566,14 +566,14 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_chrono { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse( - basic_format_parse_context<_CharT>& __parse_ctx, __format_spec::__fields __fields, __format_spec::__flags __flags) - -> decltype(__parse_ctx.begin()) { - return __parser_.__parse(__parse_ctx, __fields, __flags); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator + __parse(_ParseContext& __ctx, __format_spec::__fields __fields, __format_spec::__flags __flags) { + return __parser_.__parse(__ctx, __fields, __flags); } - template - _LIBCPP_HIDE_FROM_ABI auto format(const _Tp& __value, auto& __ctx) const -> decltype(__ctx.out()) const { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __value, _FormatContext& __ctx) const { return __formatter::__format_chrono( __value, __ctx, __parser_.__parser_.__get_parsed_chrono_specifications(__ctx), __parser_.__chrono_specs_); } @@ -586,9 +586,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); } }; @@ -597,9 +597,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); } }; @@ -608,10 +608,10 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { // The flags are not __clock since there is no associated time-zone. - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date_time); + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date_time); } }; @@ -620,8 +620,8 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { // [time.format]/1 // Giving a precision specification in the chrono-format-spec is valid only // for std::chrono::duration types where the representation type Rep is a @@ -631,9 +631,9 @@ // // Note this doesn't refer to chrono::treat_as_floating_point_v<_Rep>. if constexpr (std::floating_point<_Rep>) - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono_fractional, __format_spec::__flags::__duration); + return _Base::__parse(__ctx, __format_spec::__fields_chrono_fractional, __format_spec::__flags::__duration); else - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__duration); + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__duration); } }; @@ -643,9 +643,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__day); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__day); } }; @@ -655,9 +655,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month); } }; @@ -667,9 +667,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year); } }; @@ -679,9 +679,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); } }; @@ -691,9 +691,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); } }; @@ -703,9 +703,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday); } }; @@ -715,9 +715,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_day); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_day); } }; @@ -727,9 +727,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month); } }; @@ -739,9 +739,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday); } }; @@ -751,9 +751,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday); } }; @@ -763,9 +763,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year_month); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year_month); } }; @@ -775,9 +775,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); } }; @@ -787,9 +787,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); } }; @@ -799,9 +799,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); } }; @@ -811,9 +811,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date); } }; @@ -822,9 +822,9 @@ public: using _Base = __formatter_chrono<_CharT>; - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time); } }; #endif // if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h --- a/libcxx/include/__chrono/parser_std_format_spec.h +++ b/libcxx/include/__chrono/parser_std_format_spec.h @@ -140,11 +140,11 @@ using _ConstIterator = typename basic_format_parse_context<_CharT>::const_iterator; public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields, __flags __flags) - -> decltype(__parse_ctx.begin()) { - _ConstIterator __begin = __parser_.__parse(__parse_ctx, __fields); - _ConstIterator __end = __parse_ctx.end(); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator + __parse(_ParseContext& __ctx, __fields __fields, __flags __flags) { + _ConstIterator __begin = __parser_.__parse(__ctx, __fields); + _ConstIterator __end = __ctx.end(); if (__begin == __end) return __begin; diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h --- a/libcxx/include/__format/format_functions.h +++ b/libcxx/include/__format/format_functions.h @@ -89,14 +89,16 @@ template class _LIBCPP_TEMPLATE_VIS __compile_time_handle { public: - _LIBCPP_HIDE_FROM_ABI - constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); } + template + _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const { + __parse_(__ctx); + } template _LIBCPP_HIDE_FROM_ABI constexpr void __enable() { - __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) { + __parse_ = [](basic_format_parse_context<_CharT>& __ctx) { formatter<_Tp, _CharT> __f; - __parse_ctx.advance_to(__f.parse(__parse_ctx)); + __ctx.advance_to(__f.parse(__ctx)); }; } diff --git a/libcxx/include/__format/formatter_bool.h b/libcxx/include/__format/formatter_bool.h --- a/libcxx/include/__format/formatter_bool.h +++ b/libcxx/include/__format/formatter_bool.h @@ -38,14 +38,15 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_integral); __format_spec::__process_parsed_bool(__parser_); return __result; } - _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(bool __value, _FormatContext& __ctx) const { switch (__parser_.__type_) { case __format_spec::__type::__default: case __format_spec::__type::__string: diff --git a/libcxx/include/__format/formatter_char.h b/libcxx/include/__format/formatter_char.h --- a/libcxx/include/__format/formatter_char.h +++ b/libcxx/include/__format/formatter_char.h @@ -33,14 +33,15 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_char { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_integral); __format_spec::__process_parsed_char(__parser_); return __result; } - _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT __value, _FormatContext& __ctx) const { if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char) return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); @@ -60,7 +61,8 @@ return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); } - _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out()) + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(char __value, _FormatContext& __ctx) const requires(same_as<_CharT, wchar_t>) { return format(static_cast(__value), __ctx); diff --git a/libcxx/include/__format/formatter_floating_point.h b/libcxx/include/__format/formatter_floating_point.h --- a/libcxx/include/__format/formatter_floating_point.h +++ b/libcxx/include/__format/formatter_floating_point.h @@ -608,10 +608,9 @@ return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs); } -template -_LIBCPP_HIDE_FROM_ABI auto -__format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) - -> decltype(__ctx.out()) { +template +_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator +__format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) { bool __negative = _VSTD::signbit(__value); if (!_VSTD::isfinite(__value)) [[unlikely]] @@ -728,15 +727,15 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_floating_point); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_floating_point); __format_spec::__process_parsed_floating_point(__parser_); return __result; } - template - _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_Tp __value, _FormatContext& __ctx) const { return __formatter::__format_floating_point(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); } diff --git a/libcxx/include/__format/formatter_integer.h b/libcxx/include/__format/formatter_integer.h --- a/libcxx/include/__format/formatter_integer.h +++ b/libcxx/include/__format/formatter_integer.h @@ -34,15 +34,15 @@ struct _LIBCPP_TEMPLATE_VIS __formatter_integer { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_integral); __format_spec::__process_parsed_integer(__parser_); return __result; } - template - _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_Tp __value, _FormatContext& __ctx) const { __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); if (__specs.__std_.__type_ == __format_spec::__type::__char) diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h --- a/libcxx/include/__format/formatter_integral.h +++ b/libcxx/include/__format/formatter_integral.h @@ -203,16 +203,16 @@ + 1; // Reserve space for the sign. } -template -_LIBCPP_HIDE_FROM_ABI auto __format_integer( +template +_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer( _Tp __value, - auto& __ctx, + _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative, char* __begin, char* __end, const char* __prefix, - int __base) -> decltype(__ctx.out()) { + int __base) { char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_); if (__specs.__std_.__alternate_form_ && __prefix) while (*__prefix) @@ -263,10 +263,12 @@ return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper); } -template -_LIBCPP_HIDE_FROM_ABI auto __format_integer( - _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false) - -> decltype(__ctx.out()) { +template +_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator +__format_integer(_Tp __value, + _FormatContext& __ctx, + __format_spec::__parsed_specifications<_CharT> __specs, + bool __negative = false) { switch (__specs.__std_.__type_) { case __format_spec::__type::__binary_lower_case: { array()> __array; @@ -302,10 +304,9 @@ } } -template -_LIBCPP_HIDE_FROM_ABI auto -__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) - -> decltype(__ctx.out()) { +template +_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator +__format_integer(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) { // Depending on the std-format-spec string the sign and the value // might not be outputted together: // - alternate form may insert a prefix string. @@ -341,10 +342,9 @@ }; # endif -template -_LIBCPP_HIDE_FROM_ABI auto -__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) - -> decltype(__ctx.out()) { +template +_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator +__format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) { # ifndef _LIBCPP_HAS_NO_LOCALIZATION if (__specs.__std_.__locale_specific_form_) { const auto& __np = std::use_facet>(__ctx.locale()); diff --git a/libcxx/include/__format/formatter_pointer.h b/libcxx/include/__format/formatter_pointer.h --- a/libcxx/include/__format/formatter_pointer.h +++ b/libcxx/include/__format/formatter_pointer.h @@ -32,14 +32,15 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_pointer { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto - parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_pointer); __format_spec::__process_display_type_pointer(__parser_.__type_); return __result; } - _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const void* __ptr, _FormatContext& __ctx) const { __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); __specs.__std_.__alternate_form_ = true; __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case; diff --git a/libcxx/include/__format/formatter_string.h b/libcxx/include/__format/formatter_string.h --- a/libcxx/include/__format/formatter_string.h +++ b/libcxx/include/__format/formatter_string.h @@ -32,14 +32,16 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS __formatter_string { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_string); __format_spec::__process_display_type_string(__parser_.__type_); return __result; } - _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator + format(basic_string_view<_CharT> __str, _FormatContext& __ctx) const { # if _LIBCPP_STD_VER >= 23 if (__parser_.__type_ == __format_spec::__type::__debug) return __formatter::__format_escaped_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); @@ -61,7 +63,8 @@ : public __formatter_string<_CharT> { using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _CharT* __str, _FormatContext& __ctx) const { _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have " "prevented an invalid pointer."); @@ -99,7 +102,8 @@ : public formatter { using _Base = formatter; - _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT* __str, _FormatContext& __ctx) const { return _Base::format(__str, __ctx); } }; @@ -110,7 +114,8 @@ : public __formatter_string<_CharT> { using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT __str[_Size], _FormatContext& __ctx) const { return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); } }; @@ -121,8 +126,9 @@ : public __formatter_string<_CharT> { using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const - -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator + format(const basic_string<_CharT, _Traits, _Allocator>& __str, _FormatContext& __ctx) const { // Drop _Traits and _Allocator to have one std::basic_string formatter. return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); } @@ -134,8 +140,9 @@ : public __formatter_string<_CharT> { using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const - -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator + format(basic_string_view<_CharT, _Traits> __str, _FormatContext& __ctx) const { // Drop _Traits to have one std::basic_string_view formatter. return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); } diff --git a/libcxx/include/__format/formatter_tuple.h b/libcxx/include/__format/formatter_tuple.h --- a/libcxx/include/__format/formatter_tuple.h +++ b/libcxx/include/__format/formatter_tuple.h @@ -50,10 +50,10 @@ } template - _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) { - auto __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_tuple); + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + auto __begin = __parser_.__parse(__ctx, __format_spec::__fields_tuple); - auto __end = __parse_ctx.end(); + auto __end = __ctx.end(); if (__begin != __end) { if (*__begin == _CharT('m')) { if constexpr (sizeof...(_Args) == 2) { @@ -71,14 +71,14 @@ if (__begin != __end && *__begin != _CharT('}')) std::__throw_format_error("The format-spec should consume the input or end with a '}'"); - __parse_ctx.advance_to(__begin); + __ctx.advance_to(__begin); // [format.tuple]/7 // ... For each element e in underlying_, if e.set_debug_format() // is a valid expression, calls e.set_debug_format(). std::__for_each_index_sequence(make_index_sequence(), [&] { auto& __formatter = std::get<_Index>(__underlying_); - __formatter.parse(__parse_ctx); + __formatter.parse(__ctx); // Unlike the range_formatter we don't guard against evil parsers. Since // this format-spec never has a format-spec for the underlying type // adding the test would give additional overhead. diff --git a/libcxx/include/__format/parser_std_format_spec.h b/libcxx/include/__format/parser_std_format_spec.h --- a/libcxx/include/__format/parser_std_format_spec.h +++ b/libcxx/include/__format/parser_std_format_spec.h @@ -50,16 +50,16 @@ namespace __format_spec { -template +template _LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result<_Iterator> -__parse_arg_id(_Iterator __begin, _Iterator __end, auto& __parse_ctx) { +__parse_arg_id(_Iterator __begin, _Iterator __end, _ParseContext& __ctx) { using _CharT = iter_value_t<_Iterator>; // This function is a wrapper to call the real parser. But it does the // validation for the pre-conditions and post-conditions. if (__begin == __end) std::__throw_format_error("End of input while parsing format-spec arg-id"); - __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx); + __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __ctx); if (__r.__last == __end || *__r.__last != _CharT('}')) std::__throw_format_error("Invalid arg-id"); @@ -282,11 +282,10 @@ template class _LIBCPP_TEMPLATE_VIS __parser { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields) - -> decltype(__parse_ctx.begin()) { - - auto __begin = __parse_ctx.begin(); - auto __end = __parse_ctx.end(); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator __parse(_ParseContext& __ctx, __fields __fields) { + auto __begin = __ctx.begin(); + auto __end = __ctx.end(); if (__begin == __end) return __begin; @@ -302,10 +301,10 @@ if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end) return __begin; - if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end) + if (__parse_width(__begin, __end, __ctx) && __begin == __end) return __begin; - if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end) + if (__fields.__precision_ && __parse_precision(__begin, __end, __ctx) && __begin == __end) return __begin; if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end) @@ -476,12 +475,12 @@ } template - _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(_Iterator& __begin, _Iterator __end, auto& __parse_ctx) { + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(_Iterator& __begin, _Iterator __end, auto& __ctx) { if (*__begin == _CharT('0')) std::__throw_format_error("A format-spec width field shouldn't have a leading zero"); if (*__begin == _CharT('{')) { - __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); + __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __ctx); __width_as_arg_ = true; __width_ = __r.__value; __begin = __r.__last; @@ -500,7 +499,7 @@ } template - _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(_Iterator& __begin, _Iterator __end, auto& __parse_ctx) { + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(_Iterator& __begin, _Iterator __end, auto& __ctx) { if (*__begin != _CharT('.')) return false; @@ -509,7 +508,7 @@ std::__throw_format_error("End of input while parsing format-spec precision"); if (*__begin == _CharT('{')) { - __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); + __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __ctx); __precision_as_arg_ = true; __precision_ = __arg_id.__value; __begin = __arg_id.__last; diff --git a/libcxx/include/__format/range_formatter.h b/libcxx/include/__format/range_formatter.h --- a/libcxx/include/__format/range_formatter.h +++ b/libcxx/include/__format/range_formatter.h @@ -54,15 +54,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr const formatter<_Tp, _CharT>& underlying() const noexcept { return __underlying_; } template - _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) { - auto __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_range); - auto __end = __parse_ctx.end(); + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + auto __begin = __parser_.__parse(__ctx, __format_spec::__fields_range); + auto __end = __ctx.end(); // Note the cases where __begin == __end in this code only happens when the // replacement-field has no terminating }, or when the parse is manually // called with a format-spec. The former is an error and the latter means // using a formatter without the format functions or print. if (__begin == __end) [[unlikely]] - return __parse_empty_range_underlying_spec(__parse_ctx, __begin); + return __parse_empty_range_underlying_spec(__ctx, __begin); // The n field overrides a possible m type, therefore delay applying the // effect of n until the type has been procesed. @@ -72,7 +72,7 @@ if (__begin == __end) [[unlikely]] { // Since there is no more data, clear the brackets before returning. set_brackets({}, {}); - return __parse_empty_range_underlying_spec(__parse_ctx, __begin); + return __parse_empty_range_underlying_spec(__ctx, __begin); } } @@ -80,7 +80,7 @@ if (__clear_brackets) set_brackets({}, {}); if (__begin == __end) [[unlikely]] - return __parse_empty_range_underlying_spec(__parse_ctx, __begin); + return __parse_empty_range_underlying_spec(__ctx, __begin); bool __has_range_underlying_spec = *__begin == _CharT(':'); if (__has_range_underlying_spec) { @@ -95,8 +95,8 @@ // get -} as input which my be valid. std::__throw_format_error("The format-spec should consume the input or end with a '}'"); - __parse_ctx.advance_to(__begin); - __begin = __underlying_.parse(__parse_ctx); + __ctx.advance_to(__begin); + __begin = __underlying_.parse(__ctx); // This test should not be required if __has_range_underlying_spec is false. // However this test makes sure the underlying formatter left the parser in @@ -260,9 +260,9 @@ template _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator - __parse_empty_range_underlying_spec(_ParseContext& __parse_ctx, typename _ParseContext::iterator __begin) { - __parse_ctx.advance_to(__begin); - [[maybe_unused]] typename _ParseContext::iterator __result = __underlying_.parse(__parse_ctx); + __parse_empty_range_underlying_spec(_ParseContext& __ctx, typename _ParseContext::iterator __begin) { + __ctx.advance_to(__begin); + [[maybe_unused]] typename _ParseContext::iterator __result = __underlying_.parse(__ctx); _LIBCPP_ASSERT(__result == __begin, "the underlying's parse function should not advance the input beyond the end of the input"); return __begin; diff --git a/libcxx/include/thread b/libcxx/include/thread --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -240,12 +240,13 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - return __parser_.__parse(__parse_ctx, __format_spec::__fields_fill_align_width); + template + _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { + return __parser_.__parse(__ctx, __format_spec::__fields_fill_align_width); } - _LIBCPP_HIDE_FROM_ABI auto format(__thread_id __id, auto& __ctx) const -> decltype(__ctx.out()) { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(__thread_id __id, _FormatContext& __ctx) const { // In __threading_support __libcpp_thread_id is either a // unsigned long long or a pthread_t. //