mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 19:24:48 +02: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:
@@ -16,6 +16,7 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "format.h"
|
||||||
#include "ostream.h"
|
#include "ostream.h"
|
||||||
|
|
||||||
#if FMT_HAS_INCLUDE(<version>)
|
#if FMT_HAS_INCLUDE(<version>)
|
||||||
@@ -234,13 +235,14 @@ struct formatter<
|
|||||||
auto out = ctx.out();
|
auto out = ctx.out();
|
||||||
|
|
||||||
out = detail::write<Char>(out, "variant(");
|
out = detail::write<Char>(out, "variant(");
|
||||||
try {
|
FMT_TRY {
|
||||||
std::visit(
|
std::visit(
|
||||||
[&](const auto& v) {
|
[&](const auto& v) {
|
||||||
out = detail::write_variant_alternative<Char>(out, v);
|
out = detail::write_variant_alternative<Char>(out, v);
|
||||||
},
|
},
|
||||||
value);
|
value);
|
||||||
} catch (const std::bad_variant_access&) {
|
}
|
||||||
|
FMT_CATCH(const std::bad_variant_access&) {
|
||||||
detail::write<Char>(out, "valueless by exception");
|
detail::write<Char>(out, "valueless by exception");
|
||||||
}
|
}
|
||||||
*out++ = ')';
|
*out++ = ')';
|
||||||
|
Reference in New Issue
Block a user