Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FMT_TRY and FMT_CATCH in std.h #3482

Merged
merged 1 commit into from
Jun 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <typeinfo>
#include <utility>

#include "format.h"
#include "ostream.h"

#if FMT_HAS_INCLUDE(<version>)
Expand Down Expand Up @@ -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++ = ')';
Expand Down