diff --git a/include/fmt/base.h b/include/fmt/base.h index 0d97dc7b..96e31ea2 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1006,7 +1006,7 @@ struct format_specs : basic_specs { * You can use the `format_parse_context` type alias for `char` instead. */ FMT_EXPORT -template class parse_context { +template class parse_context { private: basic_string_view format_str_; int next_arg_id_; diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 5aca22f9..583d07f6 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -2098,7 +2098,7 @@ struct formatter : private formatter { bool use_tm_formatter_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); if (it != end && *it == 'L') { ++it; @@ -2127,7 +2127,7 @@ struct formatter : private formatter { bool use_tm_formatter_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); use_tm_formatter_ = it != end && *it != '}'; return use_tm_formatter_ ? formatter::parse(ctx) : it; @@ -2152,7 +2152,7 @@ struct formatter : private formatter { bool use_tm_formatter_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); if (it != end && *it == 'L') { ++it; @@ -2181,7 +2181,7 @@ struct formatter : private formatter { bool use_tm_formatter_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); use_tm_formatter_ = it != end && *it != '}'; return use_tm_formatter_ ? formatter::parse(ctx) : it; @@ -2205,7 +2205,7 @@ struct formatter : private formatter { bool use_tm_formatter_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); use_tm_formatter_ = it != end && *it != '}'; return use_tm_formatter_ ? formatter::parse(ctx) : it; @@ -2236,7 +2236,7 @@ struct formatter, Char> { basic_string_view format_str_; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); if (it == end || *it == '}') return it; @@ -2321,7 +2321,7 @@ template struct formatter { } public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); if (it == end || *it == '}') return it; diff --git a/include/fmt/format.h b/include/fmt/format.h index 6cc42cf5..a750c9f6 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -4015,8 +4015,7 @@ template <> struct formatter { detail::dynamic_format_specs<> specs_; public: - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> const char* { + FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* { return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx, detail::type::string_type); } @@ -4055,8 +4054,7 @@ template struct formatter> : formatter { detail::dynamic_format_specs<> specs_; public: - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> const char* { + FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* { return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx, detail::type::int_type); } @@ -4083,8 +4081,7 @@ template struct nested_view { template struct formatter, Char> { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } template @@ -4103,7 +4100,7 @@ template struct nested_formatter { public: constexpr nested_formatter() : width_(0) {} - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(), end = ctx.end(); if (it == end) return it; auto specs = format_specs(); diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index b402b465..cbc12b2a 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -266,12 +266,12 @@ template using range_format_constant = std::integral_constant; // These are not generic lambdas for compatibility with C++11. -template struct parse_empty_specs { +template struct parse_empty_specs { template FMT_CONSTEXPR void operator()(Formatter& f) { f.parse(ctx); detail::maybe_set_debug_format(f, true); } - ParseContext& ctx; + parse_context& ctx; }; template struct format_tuple_element { using char_type = typename FormatContext::char_type; @@ -327,8 +327,7 @@ struct formatter - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(); auto end = ctx.end(); if (it != end && detail::to_ascii(*it) == 'n') { @@ -338,7 +337,7 @@ struct formatter{ctx}); + detail::for_each(formatters_, detail::parse_empty_specs{ctx}); return it; } @@ -449,8 +448,7 @@ struct range_formatter< closing_bracket_ = close; } - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(); auto end = ctx.end(); detail::maybe_set_debug_format(underlying_, true); @@ -549,8 +547,7 @@ struct formatter< detail::string_literal{}); } - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return range_formatter_.parse(ctx); } @@ -577,8 +574,7 @@ struct formatter< public: FMT_CONSTEXPR formatter() {} - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(); auto end = ctx.end(); if (it != end) { @@ -592,7 +588,7 @@ struct formatter< } ctx.advance_to(it); } - detail::for_each(formatters_, detail::parse_empty_specs{ctx}); + detail::for_each(formatters_, detail::parse_empty_specs{ctx}); return it; } @@ -637,8 +633,7 @@ struct formatter< formatter underlying_; public: - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return underlying_.parse(ctx); } @@ -686,8 +681,7 @@ struct formatter, Char> { public: using nonlocking = void; - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> const Char* { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return value_formatter_.parse(ctx); } @@ -754,8 +748,7 @@ template struct tuple_join_view : detail::view { template struct formatter, Char> { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return do_parse(ctx, std::integral_constant()); } @@ -769,17 +762,16 @@ struct formatter, Char> { private: std::tuple::type, Char>...> formatters_; - template - FMT_CONSTEXPR auto do_parse(ParseContext& ctx, + FMT_CONSTEXPR auto do_parse(parse_context& ctx, std::integral_constant) - -> decltype(ctx.begin()) { + -> const Char* { return ctx.begin(); } - template - FMT_CONSTEXPR auto do_parse(ParseContext& ctx, + template + FMT_CONSTEXPR auto do_parse(parse_context& ctx, std::integral_constant) - -> decltype(ctx.begin()) { + -> const Char* { auto end = ctx.begin(); #if FMT_TUPLE_JOIN_SPECIFIERS end = std::get(formatters_).parse(ctx); diff --git a/include/fmt/std.h b/include/fmt/std.h index 9a4a0b48..28460846 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -122,7 +122,7 @@ template struct formatter { public: FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; } - template FMT_CONSTEXPR auto parse(ParseContext& ctx) { + FMT_CONSTEXPR auto parse(parse_context& ctx) { auto it = ctx.begin(), end = ctx.end(); if (it == end) return it; @@ -235,7 +235,7 @@ struct formatter, Char, FMT_CONSTEXPR static void maybe_set_debug_format(U&, ...) {} public: - template FMT_CONSTEXPR auto parse(ParseContext& ctx) { + FMT_CONSTEXPR auto parse(parse_context& ctx) { maybe_set_debug_format(underlying_, true); return underlying_.parse(ctx); } @@ -281,8 +281,7 @@ template struct formatter, Char, std::enable_if_t::value && is_formattable::value>> { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } @@ -309,9 +308,7 @@ FMT_END_NAMESPACE FMT_BEGIN_NAMESPACE FMT_EXPORT template <> struct formatter { - template FMT_CONSTEXPR auto parse(ParseContext& ctx) { - return ctx.begin(); - } + FMT_CONSTEXPR auto parse(parse_context<>& ctx) { return ctx.begin(); } template auto format(const std::source_location& loc, FormatContext& ctx) const @@ -367,8 +364,7 @@ template struct is_variant_formattable { FMT_EXPORT template struct formatter { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } @@ -385,8 +381,7 @@ struct formatter< Variant, Char, std::enable_if_t, is_variant_formattable>>> { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } @@ -416,8 +411,7 @@ FMT_END_NAMESPACE FMT_BEGIN_NAMESPACE FMT_EXPORT template struct formatter { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } @@ -508,7 +502,7 @@ template struct formatter { public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { return ctx.begin(); } @@ -529,7 +523,7 @@ struct formatter< bool with_typename_ = false; public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { auto it = ctx.begin(); auto end = ctx.end(); if (it == end || *it == '}') return it; @@ -657,7 +651,7 @@ template struct formatter, Char> { } public: - FMT_CONSTEXPR auto parse(parse_context& ctx) -> decltype(ctx.begin()) { + FMT_CONSTEXPR auto parse(parse_context& ctx) -> const Char* { if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin(); return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx, detail::type_constant::value);