From f20f50368f17ec871c91b1cc7f4372fff5704a26 Mon Sep 17 00:00:00 2001 From: Johnathan <39648915+TrebledJ@users.noreply.github.com> Date: Sun, 18 Jul 2021 22:08:24 +0800 Subject: [PATCH] Replace `throw` with `FMT_THROW` (#2427) Using `throw` results in compile errors with `-fno-exceptions`. gcc seems fine with it, but arm-gcc and clang would complain. --- include/fmt/compile.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 00000c92..97e1240e 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -289,7 +289,7 @@ template struct runtime_named_field { constexpr OutputIt format(OutputIt out, const Args&... args) const { bool found = (try_format_argument(out, name, args) || ...); if (!found) { - throw format_error("argument with specified name is not found"); + FMT_THROW(format_error("argument with specified name is not found")); } return out; } @@ -399,7 +399,7 @@ template struct arg_id_handler { return 0; } - constexpr void on_error(const char* message) { throw format_error(message); } + constexpr void on_error(const char* message) { FMT_THROW(format_error(message)); } }; template struct parse_arg_id_result { @@ -451,7 +451,7 @@ constexpr auto compile_format_string(S format_str) { constexpr auto str = basic_string_view(format_str); if constexpr (str[POS] == '{') { if constexpr (POS + 1 == str.size()) - throw format_error("unmatched '{' in format string"); + FMT_THROW(format_error("unmatched '{' in format string")); if constexpr (str[POS + 1] == '{') { return parse_tail(make_text(str, POS, 1), format_str); } else if constexpr (str[POS + 1] == '}' || str[POS + 1] == ':') { @@ -500,7 +500,7 @@ constexpr auto compile_format_string(S format_str) { } } else if constexpr (str[POS] == '}') { if constexpr (POS + 1 == str.size()) - throw format_error("unmatched '}' in format string"); + FMT_THROW(format_error("unmatched '}' in format string")); return parse_tail(make_text(str, POS, 1), format_str); } else { constexpr auto end = parse_text(str, POS + 1);