diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-05 15:45:24 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-05 15:54:16 +0200 |
| commit | dc7d7bc45d9b6cb3a052d69fbdacbd33b9ff3796 (patch) | |
| tree | ab42a7e61784d97478e2b73f9e31ff400ccbbe09 /include | |
| parent | upgrade winapi-common (diff) | |
| download | winapi-debug-dc7d7bc45d9b6cb3a052d69fbdacbd33b9ff3796.tar.gz winapi-debug-dc7d7bc45d9b6cb3a052d69fbdacbd33b9ff3796.zip | |
upgrade to std::format
Diffstat (limited to 'include')
| -rw-r--r-- | include/winapi/debug/address.hpp | 18 |
1 files changed, 10 insertions, 8 deletions
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 <windows.h> -#include <sstream> +#include <charconv> +#include <format> #include <string> 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 |
