From de0757b578244e0bf7ac50007fb5e25fcc899c7c Mon Sep 17 00:00:00 2001 From: Minty-Meeo <45425365+Minty-Meeo@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:28:13 -0500 Subject: [PATCH] Use FMT_TRY and FMT_CATCH in std.h (#3482) This naked try-catch block prevents compilation when exceptions are disabled. --- include/fmt/std.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fmt/std.h b/include/fmt/std.h index b686d0e1..f5236715 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -16,6 +16,7 @@ #include #include +#include "format.h" #include "ostream.h" #if FMT_HAS_INCLUDE() @@ -234,13 +235,14 @@ struct formatter< auto out = ctx.out(); out = detail::write(out, "variant("); - try { + FMT_TRY { std::visit( [&](const auto& v) { out = detail::write_variant_alternative(out, v); }, value); - } catch (const std::bad_variant_access&) { + } + FMT_CATCH(const std::bad_variant_access&) { detail::write(out, "valueless by exception"); } *out++ = ')';