From 175103e8d40470f93dcaaeb82bc541a0a2079006 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jul 2024 09:56:31 +0200 Subject: [PATCH] lib/fmt/ExceptionFormatter: un-inline to reduce header dependencies --- src/lib/fmt/ExceptionFormatter.cxx | 12 ++++++++++++ src/lib/fmt/ExceptionFormatter.hxx | 14 ++++---------- src/lib/fmt/meson.build | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/lib/fmt/ExceptionFormatter.cxx diff --git a/src/lib/fmt/ExceptionFormatter.cxx b/src/lib/fmt/ExceptionFormatter.cxx new file mode 100644 index 000000000..ebbd0d9fe --- /dev/null +++ b/src/lib/fmt/ExceptionFormatter.cxx @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: BSD-2-Clause +// author: Max Kellermann + +#include "ExceptionFormatter.hxx" +#include "util/Exception.hxx" + +auto +fmt::formatter::format(std::exception_ptr e, format_context &ctx) const + -> format_context::iterator +{ + return formatter::format(GetFullMessage(e), ctx); +} diff --git a/src/lib/fmt/ExceptionFormatter.hxx b/src/lib/fmt/ExceptionFormatter.hxx index f08b3bb22..f1cfdc684 100644 --- a/src/lib/fmt/ExceptionFormatter.hxx +++ b/src/lib/fmt/ExceptionFormatter.hxx @@ -1,20 +1,14 @@ // SPDX-License-Identifier: BSD-2-Clause // author: Max Kellermann -#ifndef EXCEPTION_FORMATTER_HXX -#define EXCEPTION_FORMATTER_HXX - -#include "util/Exception.hxx" +#pragma once #include +#include + template<> struct fmt::formatter : formatter { - template - auto format(std::exception_ptr e, FormatContext &ctx) const { - return formatter::format(GetFullMessage(e), ctx); - } + auto format(std::exception_ptr e, format_context &ctx) const -> format_context::iterator; }; - -#endif diff --git a/src/lib/fmt/meson.build b/src/lib/fmt/meson.build index b0237fd0a..6ed2dc080 100644 --- a/src/lib/fmt/meson.build +++ b/src/lib/fmt/meson.build @@ -10,6 +10,7 @@ endif fmt = static_library( 'fmt', + 'ExceptionFormatter.cxx', 'RuntimeError.cxx', 'SocketAddressFormatter.cxx', 'SystemError.cxx',