From dc7d7bc45d9b6cb3a052d69fbdacbd33b9ff3796 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 5 Jun 2026 15:45:24 +0200 Subject: upgrade to std::format --- include/winapi/debug/address.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'include/winapi/debug') diff --git a/include/winapi/debug/address.hpp b/include/winapi/debug/address.hpp index e5db42d..a5f186e 100644 --- a/include/winapi/debug/address.hpp +++ b/include/winapi/debug/address.hpp @@ -7,7 +7,8 @@ #include -#include +#include +#include #include namespace winapi { @@ -17,9 +18,7 @@ typedef DWORD64 Address; namespace address { inline std::string format(Address address) { - std::ostringstream oss; - oss << std::hex << std::showbase << address; - return oss.str(); + return std::format("{:#x}", address); } inline std::string format(void* address) { @@ -27,10 +26,13 @@ inline std::string format(void* address) { } inline bool parse(Address& dest, const std::string& src) { - std::istringstream iss{src}; - iss >> std::hex; - char c; - return iss >> dest && !iss.get(c); + Address result; + const auto [ptr, ec] = std::from_chars(src.c_str(), src.c_str() + src.length(), result, 16); + if (ec == std::errc()) { + dest = result; + return true; + } + return false; } } // namespace address -- cgit v1.3