mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-05 00:40:12 +00:00
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:
parent
8fe893c0ac
commit
de0757b578
@ -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++ = ')';
|
||||
|
Loading…
x
Reference in New Issue
Block a user