Skip to content

Commit

Permalink
Dedup throw_format_error
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jan 2, 2024
1 parent 9659f22 commit f4a7d40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,13 +657,10 @@ enum {
cstring_set = set(type::cstring_type),
pointer_set = set(type::pointer_type)
};

// DEPRECATED!
FMT_NORETURN FMT_API void throw_format_error(const char* message);
} // namespace detail

/** Throws ``format_error`` with a given message. */
using detail::throw_format_error;
FMT_NORETURN FMT_API void throw_format_error(const char* message);

/** String's character type. */
template <typename S> using char_t = typename detail::char_t_impl<S>::type;
Expand Down Expand Up @@ -715,7 +712,7 @@ template <typename Char> class basic_format_parse_context {
*/
FMT_CONSTEXPR auto next_arg_id() -> int {
if (next_arg_id_ < 0) {
detail::throw_format_error(
throw_format_error(
"cannot switch from manual to automatic argument indexing");
return 0;
}
Expand All @@ -730,7 +727,7 @@ template <typename Char> class basic_format_parse_context {
*/
FMT_CONSTEXPR void check_arg_id(int id) {
if (next_arg_id_ > 0) {
detail::throw_format_error(
throw_format_error(
"cannot switch from automatic to manual argument indexing");
return;
}
Expand Down Expand Up @@ -1068,7 +1065,7 @@ FMT_CONSTEXPR void basic_format_parse_context<Char>::do_check_arg_id(int id) {
(!FMT_GCC_VERSION || FMT_GCC_VERSION >= 1200)) {
using context = detail::compile_parse_context<Char>;
if (id >= static_cast<context*>(this)->num_args())
detail::throw_format_error("argument not found");
throw_format_error("argument not found");
}
}

Expand Down
8 changes: 4 additions & 4 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
std::terminate();
}

FMT_FUNC void throw_format_error(const char* message) {
FMT_THROW(format_error(message));
}

FMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,
string_view message) noexcept {
// Report error code making sure that the output fits into
Expand Down Expand Up @@ -127,6 +123,10 @@ FMT_FUNC auto write_loc(appender out, loc_value value,
}
} // namespace detail

FMT_FUNC void throw_format_error(const char* message) {
FMT_THROW(format_error(message));
}

template <typename Locale> typename Locale::id format_facet<Locale>::id;

#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
Expand Down

0 comments on commit f4a7d40

Please sign in to comment.