static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
-template <class _CharT, class _Tp>
+template <class _CharT, class _Tp, class _FormatContext>
_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
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 <class _ParseContext>
+ _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 <class _Tp>
- _LIBCPP_HIDE_FROM_ABI auto format(const _Tp& __value, auto& __ctx) const -> decltype(__ctx.out()) const {
+ template <class _Tp, class _FormatContext>
+ _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_);
}
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
}
};
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 <class _ParseContext>
+ _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);
}
};
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 <class _ParseContext>
+ _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
//
// 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);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__day);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_day);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year_month);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
}
};
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
+ return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
}
};
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 <class _ParseContext>
+ _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)
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 <class _ParseContext>
+ _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;
template <class _CharT>
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 <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const {
+ __parse_(__ctx);
+ }
template <class _Tp>
_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));
};
}
template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS formatter<bool, _CharT> {
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 <class _ParseContext>
+ _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 <class _FormatContext>
+ _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:
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 <class _ParseContext>
+ _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 <class _FormatContext>
+ _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));
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 <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(char __value, _FormatContext& __ctx) const
requires(same_as<_CharT, wchar_t>)
{
return format(static_cast<wchar_t>(__value), __ctx);
return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs);
}
-template <floating_point _Tp, class _CharT>
-_LIBCPP_HIDE_FROM_ABI auto
-__format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
- -> decltype(__ctx.out()) {
+template <floating_point _Tp, class _CharT, class _FormatContext>
+_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]]
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 <class _ParseContext>
+ _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 <floating_point _Tp>
- _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ template <floating_point _Tp, class _FormatContext>
+ _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));
}
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 <class _ParseContext>
+ _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 <integral _Tp>
- _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ template <integral _Tp, class _FormatContext>
+ _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)
+ 1; // Reserve space for the sign.
}
-template <unsigned_integral _Tp, class _CharT>
-_LIBCPP_HIDE_FROM_ABI auto __format_integer(
+template <unsigned_integral _Tp, class _CharT, class _FormatContext>
+_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)
return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper);
}
-template <unsigned_integral _Tp, class _CharT>
-_LIBCPP_HIDE_FROM_ABI auto __format_integer(
- _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false)
- -> decltype(__ctx.out()) {
+template <unsigned_integral _Tp, class _CharT, class _FormatContext>
+_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<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
}
}
-template <signed_integral _Tp, class _CharT>
-_LIBCPP_HIDE_FROM_ABI auto
-__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
- -> decltype(__ctx.out()) {
+template <signed_integral _Tp, class _CharT, class _FormatContext>
+_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.
};
# endif
-template <class _CharT>
-_LIBCPP_HIDE_FROM_ABI auto
-__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
- -> decltype(__ctx.out()) {
+template <class _CharT, class _FormatContext>
+_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<numpunct<_CharT>>(__ctx.locale());
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 <class _ParseContext>
+ _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 <class _FormatContext>
+ _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;
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 <class _ParseContext>
+ _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 <class _FormatContext>
+ _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));
: 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 <class _FormatContext>
+ _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.");
: public formatter<const _CharT*, _CharT> {
using _Base = formatter<const _CharT*, _CharT>;
- _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT* __str, _FormatContext& __ctx) const {
return _Base::format(__str, __ctx);
}
};
: 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 <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT __str[_Size], _FormatContext& __ctx) const {
return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
}
};
: 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 <class _FormatContext>
+ _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);
}
: 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 <class _FormatContext>
+ _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);
}
}
template <class _ParseContext>
- _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) {
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<sizeof...(_Args)>(), [&]<size_t _Index> {
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.
namespace __format_spec {
-template <contiguous_iterator _Iterator>
+template <contiguous_iterator _Iterator, class _ParseContext>
_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");
template <class _CharT>
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 <class _ParseContext>
+ _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;
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)
}
template <contiguous_iterator _Iterator>
- _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;
}
template <contiguous_iterator _Iterator>
- _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;
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;
_LIBCPP_HIDE_FROM_ABI constexpr const formatter<_Tp, _CharT>& underlying() const noexcept { return __underlying_; }
template <class _ParseContext>
- _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.
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);
}
}
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) {
// 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
template <class _ParseContext>
_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;
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 <class _ParseContext>
+ _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 <class _FormatContext>
+ _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.
//
libcxx/include/__format/format_functions.h
libcxx/include/__format/format_parse_context.h
libcxx/include/__format/format_string.h
-libcxx/include/__format/formatter_bool.h
libcxx/include/__format/formatter_char.h
libcxx/include/__format/formatter_floating_point.h
libcxx/include/__format/formatter.h