Remove detail::error_handler

This commit is contained in:
Victor Zverovich 2024-01-01 16:10:13 -08:00
parent c142385033
commit 0b39d67103
4 changed files with 8 additions and 18 deletions

View File

@ -646,15 +646,6 @@ enum {
// DEPRECATED! // DEPRECATED!
FMT_NORETURN FMT_API void throw_format_error(const char* message); FMT_NORETURN FMT_API void throw_format_error(const char* message);
struct error_handler {
constexpr error_handler() = default;
// This function is intentionally not constexpr to give a compile-time error.
FMT_NORETURN void on_error(const char* message) {
throw_format_error(message);
}
};
} // namespace detail } // namespace detail
/** Throws ``format_error`` with a given message. */ /** Throws ``format_error`` with a given message. */
@ -1772,9 +1763,8 @@ template <typename OutputIt, typename Char> class basic_format_context {
} }
auto args() const -> const format_args& { return args_; } auto args() const -> const format_args& { return args_; }
// DEPRECATED! // This function is intentionally not constexpr to give a compile-time error.
FMT_CONSTEXPR auto error_handler() -> detail::error_handler { return {}; } void on_error(const char* message) { throw_format_error(message); }
void on_error(const char* message) { error_handler().on_error(message); }
// Returns an iterator to the beginning of the output range. // Returns an iterator to the beginning of the output range.
FMT_CONSTEXPR auto out() -> iterator { return out_; } FMT_CONSTEXPR auto out() -> iterator { return out_; }

View File

@ -4360,7 +4360,7 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
return; return;
} }
struct format_handler : error_handler { struct format_handler {
basic_format_parse_context<Char> parse_context; basic_format_parse_context<Char> parse_context;
buffer_context<Char> context; buffer_context<Char> context;
@ -4412,6 +4412,8 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
context.advance_to(visit_format_arg(f, arg)); context.advance_to(visit_format_arg(f, arg));
return begin; return begin;
} }
void on_error(const char* message) { throw_format_error(message); }
}; };
detail::parse_format_string<false>(fmt, format_handler(out, fmt, args, loc)); detail::parse_format_string<false>(fmt, format_handler(out, fmt, args, loc));
} }

View File

@ -53,9 +53,7 @@ template <typename Char> class basic_printf_context {
return args_.get(id); return args_.get(id);
} }
FMT_CONSTEXPR void on_error(const char* message) { void on_error(const char* message) { throw_format_error(message); }
detail::error_handler().on_error(message);
}
}; };
namespace detail { namespace detail {

View File

@ -573,7 +573,7 @@ struct arg_scanner {
} }
}; };
struct scan_handler : error_handler { struct scan_handler {
private: private:
scan_parse_context parse_ctx_; scan_parse_context parse_ctx_;
scan_context scan_ctx_; scan_context scan_ctx_;
@ -626,7 +626,7 @@ struct scan_handler : error_handler {
return begin; return begin;
} }
void on_error(const char* message) { error_handler::on_error(message); } void on_error(const char* message) { throw_format_error(message); }
}; };
} // namespace detail } // namespace detail