Use FMT_TRY and FMT_CATCH in std.h (#3482)

This naked try-catch block prevents compilation when exceptions are disabled.
This commit is contained in:
Minty-Meeo 2023-06-10 23:28:13 -05:00 committed by GitHub
parent 8fe893c0ac
commit de0757b578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@
#include <typeinfo>
#include <utility>
#include "format.h"
#include "ostream.h"
#if FMT_HAS_INCLUDE(<version>)
@ -234,13 +235,14 @@ struct formatter<
auto out = ctx.out();
out = detail::write<Char>(out, "variant(");
try {
FMT_TRY {
std::visit(
[&](const auto& v) {
out = detail::write_variant_alternative<Char>(out, v);
},
value);
} catch (const std::bad_variant_access&) {
}
FMT_CATCH(const std::bad_variant_access&) {
detail::write<Char>(out, "valueless by exception");
}
*out++ = ')';