From a7e7312ccacc7e9551c2eda2960a62c79bcfeb76 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 5 Mar 2021 13:36:59 +0100 Subject: [PATCH] win32/HResult: un-inline HResultCategory::message() --- src/win32/HResult.cxx | 15 +++++++++++++++ src/win32/HResult.hxx | 13 +------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/win32/HResult.cxx b/src/win32/HResult.cxx index 4397a3650..a40116a1b 100644 --- a/src/win32/HResult.cxx +++ b/src/win32/HResult.cxx @@ -19,9 +19,24 @@ #include "HResult.hxx" +#include #include +#include #include +std::string +HResultCategory::message(int Errcode) const +{ + const auto msg = HRESULTToString(Errcode); + if (!msg.empty()) + return std::string(msg); + + char buffer[11]; // "0x12345678\0" + int size = snprintf(buffer, sizeof(buffer), "0x%1x", Errcode); + assert(2 <= size && size <= 10); + return std::string(buffer, size); +} + std::system_error FormatHResultError(HRESULT result, const char *fmt, ...) noexcept { diff --git a/src/win32/HResult.hxx b/src/win32/HResult.hxx index 8ec4b30d4..2f48c08f2 100644 --- a/src/win32/HResult.hxx +++ b/src/win32/HResult.hxx @@ -22,8 +22,6 @@ #include "util/Compiler.h" -#include -#include #include #include @@ -66,16 +64,7 @@ static inline const std::error_category &hresult_category() noexcept; class HResultCategory : public std::error_category { public: const char *name() const noexcept override { return "HRESULT"; } - std::string message(int Errcode) const override { - const auto msg = HRESULTToString(Errcode); - if (!msg.empty()) { - return std::string(msg); - } - char buffer[11]; // "0x12345678\0" - int size = snprintf(buffer, sizeof(buffer), "0x%1x", Errcode); - assert(2 <= size && size <= 10); - return std::string(buffer, size); - } + std::string message(int Errcode) const override; std::error_condition default_error_condition(int code) const noexcept override { return std::error_condition(code, hresult_category()); }