aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/debug
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/winapi/debug/address.hpp18
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